Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    Westlake, Ohio, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a way to limit a field in html to only letters and dashes without scripting? I am trying to capture a field called "last name" and I do not want numbers or *()&^%$#@!+= or such. However, this form needs to be useable by anyone no matter their security regarding scripts. Any help?

    Thanks
    ...

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    Have a look at this site which will give you some direction.
    Jerry

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by timelord View Post
    Is there a way to limit a field in html to only letters and dashes without scripting?
    No, without scripting it's just a box that sits there and accepts characters until maxlength is reached.

    Of course, you will be validating the input when the page is submitted to the server, so if the user has disabled client-side scripting, you will catch it on the server and return the page to them for correction. (If you don't do server side validation, your site most likely will not be secure.)

  4. #4
    New Lounger
    Join Date
    Dec 2009
    Location
    Lancaster, Lancashire, UK
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, HTML 5 is starting to be introduced by browser vendors and has support for regular expression filters:
    http://www.whatwg.org/specs/web-apps...tern-attribute

    To be honest I'm not sure what the state of play is right now with html 5 support in the major browsers - perhaps it is time for a bit of trial and error.

    Dean

  5. #5
    New Lounger
    Join Date
    Dec 2009
    Location
    Anchorage, Alaska
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was looking to do the same thing yesterday and I found this awesome jQuery Plugin...

    VanadiumJS

    Check it out... Its pretty simple and easy to use.

    Dom

Posting Permissions

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