• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

form validation question

Guest
Jul 17, 2007 Jul 17, 2007

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

279

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 17, 2007 Jul 17, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 17, 2007 Jul 17, 2007

Copy link to clipboard

Copied

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


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation