var regx = /^[A-Za-z0-9 _.-]+$/;
if(regx.test($($input).val()))
alert ("correct");
else
alert('Incorrect!');
}
If I enter in input, character @ or # works? for me this works, but I think that must be incorrect...
Why does not works fine?
You're missing an opening brace {
Change your if ... else
statement to:
var regx = /^[A-Za-z0-9 _.-]+$/;
if (regx.test('#sdfgsdfg'))
alert("correct"); // alerts
else
alert('Incorrect!');
http://jsfiddle.net/Bp6fg/
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