If all you are trying to do is tell if the input value is a string of
spaces, you can test it using the search() method:
function isAllSpaces(inputValue) {
if(inputValue.search(/^\s*$/) != -1) {
// the string contains just spaces or is empty
return true;
} else {
// valid input
return false;
}
}
This returns true if the string is empty or it is all spaces. Changing
the * to a + will return true if it is just spaces and false if it is
empty.
> Can anyone help please.
>
> I have got a text input box on the web page and I am trying to write a
> piece of javascript that takes the value of the text box and check for
> spaces in the text. I then need to strip out the spaces and pass back the
> value and see if the lenght is 0.
>
> Basically I need to check if someone have put just a space character in
> the text box.
>
> Any help will be appreciated.
>
> Thanks
>
> Julie
>
---
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS? Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development,
Web Development, Networking & Communications, and Hardware & Systems.
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to javascript as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-javascript-$subst('Recip.MemberIDChar')@p2p.wrox.com