Results 1 to 3 of 3

Thread: Form field Limiter - Enter worth 2 help

  1. #1
    Join Date
    May 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form field Limiter - Enter worth 2 help

    Script: DD Tab Menu
    http://www.dynamicdrive.com/dynamici...limitinput.htm

    I'm just using the "Form field Limiter" script and have a problem that I can't work out.
    I need to change the counting section of the script so that the enter key is worth 2 characters instead of 1.

    I really have no idea how to change this could someone post me some code to help me please.

    A handy addon for this script I did work out was to change the value of the number of text limited if there is text in the form element when the page is loaded.

    e.g.

    *****************
    function displaylimit(thename, theid, thelimit, currentlimit){
    var theform=theid!=""? document.getElementById(theid) : thename
    var limit_text='<span id="'+theform.toString()+'">'+currentlimit+'</span> characters remaining'
    if (document.all||ns6)
    document.write(limit_text)
    if (document.all){
    eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
    eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
    }
    else if (ns6){
    document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
    document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
    }
    }
    ****************

    the currentlimit value can be worked out when creating the page asp etc. This helps if you are changing or updating information.

  2. #2
    Join Date
    May 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Any replies

    Could someone point me in the right direction to solve this problem.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In IE6 my enter key sends a carriage return and line feed so it already counts as two on the demo page for this script. Most folks use IE6. In FF only one is sent but, either is interpreted as a line break and if selected, copied and pasted on a windows based machine is interpreted as both. If it were me, I'd just live with it. Why is it so critical?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •