Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Very nice form effect

    I found a script on Dynamic Drive that allows you to restrict how many characters can be entered into a form field. Very useful if asking for state abreviations, phone numbers, zip codes, etc.

    In addition, it also tells the user how many characters they have left to type! Very nice.

    http://www.dynamicdrive.com/dynamici...limitinput.htm

    <edit my="post" />
    To add to this, there is also a form validation page which allows very strict restraints. Example, if asking for a favorite radio station, it will require the data to be in the ##.# number format. Another nice script.

    http://www.peterbailey.net/jsdemo/
    Last edited by jscript_junkie; 08-10-2002 at 04:01 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you just use the maxlength attribute of a field to limit the amount of input?

    Code:
    <input type="text" name="state" maxlength="2" />
    Happy coding!

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's what I was thinking, too. This script would be better if it just included how many characters left and use your above method to restrict length.

    My username for this service contradicts itself. I'm not a pro at JavaScript. I can just cut and paste. I only registered jscript_junkie because javascript_junkie was too long. I had that name on the old forum, though. I just like my username because it sounds cool.

    Maybe some of our JavaScript experts can put together a script that would fit the above descriptions.

  • #4
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    Doesn't maxlength only work with INPUT, and not TEXTAREA?
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, I think so. So, JavaScript would definetly be needed there. Not sure how to do that, though.

    document.forms.maxlength... Something like that.

    This is a nice script, but could use some tweaking.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmms... maybe something like whammys?

    Maxtext v1.2 (cross-browser textarea maxlength script)
    redhead

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It seems OK. I don't know the first thing about JavaScript. The things that I did understand looked very good.


  •  

    Posting Permissions

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