|
|
Check For Special Characters in JavaScript - Javascript
|
Views : 432
|
|
Tagged in : Javascript
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
You can use the below code to check special characters in javascript.
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_";
for (var i = 0; i < name.length; i++) {
if (iChars.indexOf(name.charAt(i)) != -1) {
alert ("Your string has special characters. \nThese are not allowed.");
return false;
}
} |
|
By Rekha, On - 2009-11-07 |
|
|
|