Click to See Complete Forum and Search --> : Form Validation


kapturedsoul
10-22-2003, 09:13 AM
Good morning everybody! :)

I am trying to make sure that users do not enter certain characters into a form field. I have found it will not find certain characters. For instance:

I have code like this for all of the characters I am looking for:

else if (document.contract.keywords.value.match("@") !=null)
{ window.alert ("@ is not a valid keyword.");
document.contract.keywords.focus();

return false;

and this works fine for most characters, but if I have:

else if (document.contract.keywords.value.match("(") !=null)
{ window.alert ("( is not a valid keyword.");
document.contract.keywords.focus();
return false;

Then it doesn't even find it....that goes for ) as well as 1 or 2 others.

Can anyone please help?

Gollum
10-22-2003, 09:33 AM
try...

document.contract.keywords.value.match(/[@()]/) != null


as your test (it matches everything inside the [] brackets...

kapturedsoul
10-22-2003, 09:38 AM
You ROCK!!! Thanks so much!