Skip to main content
July 17, 2007
Question

form validation question

  • July 17, 2007
  • 2 replies
  • 316 views
Okay I'm struck. I have this request:

On the form you can put a space in any of the required feilds and it will accept
the space. This is obviously a loophole around the required field that would
allow people to register without filling in their first or last name. We need
some type of validation to require alphabetical characters and not accept
spaces, symbols or numbers.


This was the request. however we need to be able to accept spaces in a last name.

I'm looking for a JavaScript that will validate

Letters of the Alphabet and Spaces Only

and then I'll need to do this on the server side in cf also.

Can someone point me in the right direction?
This topic has been closed for replies.

2 replies

Inspiring
July 18, 2007
Look into regular expressions. You can use regex to test for illegal characters (ie not a letter or space). The trim/length functions can help detect entries that consist only of whitespace. There's more to it than this, but here's a rough example to help get you started.


Inspiring
July 17, 2007
The correct answer probably includes the words "regular expression", but since that is not my strong suit, I'll stop now.