Exclude special characters in atextbox using RegExp
For example,
There is a textbox controld(id:txtName) which accepts all values except special characters like @, #
for this the RegExp should be like this:
function ExcludeSpecialCharacter()
{
var a = documnet.getElementById('txtName').value;
var aRegEx = /^[^\@\#]$/;
if(a != null)
{
if(!aRegEx.test(a))
{
alert("Name does not accept special characters like @ #.");
return false;
}
}
}
There is a textbox controld(id:txtName) which accepts all values except special characters like @, #
for this the RegExp should be like this:
function ExcludeSpecialCharacter()
{
var a = documnet.getElementById('txtName').value;
var aRegEx = /^[^\@\#]$/;
if(a != null)
{
if(!aRegEx.test(a))
{
alert("Name does not accept special characters like @ #.");
return false;
}
}
}
0 Comments:
Post a Comment
<< Home