June 16, 2008

Check if field has special characters

var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

for (var i = 0; i < document.formname.fieldname.value.length; i++) {
if (iChars.indexOf(document.formname.fieldname.value.charAt(i)) != -1) {
alert ("Your username has special characters. \nThese are not allowed.\n Please remove them and try again.");
return false;
}
}

Subscribe to

Add to Google
Add to My Yahoo!
Subscribe Via Web Feed
kick it on DotNetKicks.com