I am trying to through a erro if the user puts a special character in a form field. I have some code that works great but it saying a blank space is a invalid charachter. here is the code that is buggin...
function zipcheck() {
var mikExp = /[!\?\$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\'\:\;\""\ ]/;
if(the_form.zip.value.search(mikExp) != -1)
{
alert("Sorry, but the following characters\n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ = | : ; ! ? ' \n\r\n\rare not allowed!\n"
;
the_form.zip.focus();
return false;
}
}
function zipcheck() {
var mikExp = /[!\?\$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\'\:\;\""\ ]/;
if(the_form.zip.value.search(mikExp) != -1)
{
alert("Sorry, but the following characters\n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ = | : ; ! ? ' \n\r\n\rare not allowed!\n"
the_form.zip.focus();
return false;
}
}