Hi,
I have a form field with both the first name and the last name. The format is "last name, first name". When users update the field, I want to validate it and catch the error if comma is missing. Either javascript or cold fusion will be ok. I tried both, the problem was that comma is an operator and I couldn't escape it.
Cold fusion:
<cfif find(",", form.field) is 0>
error message here
</cfif>
Javascript:
var err = true;
var f=document.formname.fieldname.value;
for (var i=0; i < f.length; i++) {
var oneChar = f.toString().charAt(i);
if (oneChar == ","
{
err = false;
break;
}
}
if (err == true) {
alert(...);
}
Please help!!!
-J
I have a form field with both the first name and the last name. The format is "last name, first name". When users update the field, I want to validate it and catch the error if comma is missing. Either javascript or cold fusion will be ok. I tried both, the problem was that comma is an operator and I couldn't escape it.
Cold fusion:
<cfif find(",", form.field) is 0>
error message here
</cfif>
Javascript:
var err = true;
var f=document.formname.fieldname.value;
for (var i=0; i < f.length; i++) {
var oneChar = f.toString().charAt(i);
if (oneChar == ","
err = false;
break;
}
}
if (err == true) {
alert(...);
}
Please help!!!
-J