I'm trying to write a simple function to search for quotes in a CF form field (called heading).
I suspect there is some special syntax required around using quotes, since they are special characters in JS, but I'm self-taught and having trouble finding any references!
My function is as follows (executed using onClick on the form submit button):
The alert pops up regardless of whether a quote is used in the field or not...
What am I doing wrong?
I'd also like to search for double quotes ("), so any help there would also be appreciated.
Thanks in anticipation.....
Helen
I suspect there is some special syntax required around using quotes, since they are special characters in JS, but I'm self-taught and having trouble finding any references!
My function is as follows (executed using onClick on the form submit button):
Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkform(form)
{
if (form.heading.value.search(/\'/g));
{
alert("Please do not use quotes in your heading");
form.heading.focus();
return false;
}
}
// -->
</SCRIPT>
The alert pops up regardless of whether a quote is used in the field or not...
What am I doing wrong?
I'd also like to search for double quotes ("), so any help there would also be appreciated.
Thanks in anticipation.....
Helen