hi friends,
how to validate special characters in javascript with example....
like "./@#$%^&*(+)_" need to validate this special characters
thanks in advance.
Validate Special chracters in javascript
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Milstein MunakamiRank #2,283 · 617 reputationPosted Nov 9, 2013, 7:00 PM EST
Try this regex:
Also you can use
test.if (pattern.test( qry ) ) { // valid } For e.g.: function validate() { var sValue = document.getElementById("Validate").value; var pattern = /^[@!#\$\^%&*()+=\-\[\]\\\';,\.\/\{\}\|\":<>\? ]+$/; if (pattern.test(sValue)) { //Return True return true; } alert("Special Characters only !"); return false;}
manjula d131 reputationPosted Nov 14, 2013, 1:38 AM EST
function validateEmail(source, args)
{
var emialaddress = document.getElementById("#<%=txtemail.ClientId%>").val();
if(/^.@#$%^&*(+)_$/.test(emialaddress))
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}