View Full Version : how do I validate against consecutive spacebar enteries in text/textarea fields

07-05-2007, 06:24 PM
I have a form where users are hitting the spacebar to get around validation. Does anyone have validation code to recognize this and stop it? Thank you for any help you can provide.


Philip M
07-05-2007, 06:35 PM
Use a regular expression.

tmpStr = tmpStr.replace (/(^\s+)/, ""); // remove spaces at start of string

You can test your regular expressions at: http://www.ogauge.co.uk/regextester.html