I have a form. I want to put validation so that It will check if user enters white spaces or not. If its white spaces then show error. How could I do this?
In case you want to detect if there is any white space all through the user's input string,
var str = $("input").val();
if( str.indexOf(" ") !== -1 )
{
alert("bad input");
}
Example: http://jsfiddle.net/pYquc/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With