• limit field to char and dashes only

    Home » Forums » Developers, developers, developers » Web design and development » limit field to char and dashes only

    Author
    Topic
    #463714

    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

    Viewing 3 reply threads
    Author
    Replies
    • #1184808

      Have a look at this site which will give you some direction.

    • #1184847

      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.)

    • #1187682

      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/current-work/multipage/common-input-element-attributes.html#the-pattern-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

    • #1188142

      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

    Viewing 3 reply threads
    Reply To: limit field to char and dashes only

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: