Answers » Categories » Language & Reference

Can i check blank spaces in input field?

i want know whether i can check blank spaces in a input field, i can check whether the field is left empty or something is entered, but when the user just press space bar and fills blanks spaces, its assumed as something has been entered, can this be checked in javascript


1 Answer

0 

I would actually use a Regular Expression (Regex) to check for blank spaces in a textbox.

For instance the following regex should check for multiple blank white spaces on a line: ^( *)$

If you're using ASP.NET, I would use the RequiredFieldValidator control, which actually checks for blank input fields.  Or you could use a RegularExpressionValidator control and write your own regex, with the ValidationExpression="^( *)$"

Answer this question

by Anonymous - Already have an account? Login now!
Your Name:  

Your Answer:  
Source(s): (optional)

Enter the text you see in the image below
What do you see?
Can't read the image? View a new one.
Your answer will appear after being approved.

Ask your own question