Monday, 2 September 2013

Test for space input from text box

Test for space input from text box

I have a text box. I have this JS which will not allow user to enter
special characters or spaces.
var reg = /^[0-9a-zA-Z]+$/;
if(reg.test(DivisionName) == false) {
alert('Please enter Circle Name without special
characters.');
return false;
}
else{
window.location.href="addCircles.jsp?DivisionName="+DivisionName+"&cancel=";
}
Now, I want to allow user to enter special characters but not spaces. When
I remove the condition, it is allowing spaces. How can I do that?

No comments:

Post a Comment