trouble with indexof for form value

J

Jeremy

Hello,

I am trying to validate a form wherein someone will enter their first
and last name, fill out the form, then electronically "sign" at the
bottom. I want to confirm that the first and last names match in the
First & Last & Signature form fields. Here is the code I wrote, but
it doesn't work because indexof is supposed to be a string. What do I
need to do to fix this?

if (document.repForm.Signature.value.indexOf(First) == -1 ||
document.repForm. Signature.value.indexOf(Last) == "-1") {
alert("Signature does not match first and last name.");
document.repForm.Signature.focus();
return false;}


Thanks,

Jeremy
 
L

Lee

Jeremy said:
Hello,

I am trying to validate a form wherein someone will enter their first
and last name, fill out the form, then electronically "sign" at the
bottom. I want to confirm that the first and last names match in the
First & Last & Signature form fields. Here is the code I wrote, but
it doesn't work because indexof is supposed to be a string. What do I
need to do to fix this?

if (document.repForm.Signature.value.indexOf(First) == -1 ||
document.repForm. Signature.value.indexOf(Last) == "-1") {
alert("Signature does not match first and last name.");
document.repForm.Signature.focus();
return false;}

As you say, First and Last need to be strings, so simply
assign them the values of the First and Last form fields,
before you try to look for them in value of the Signature
field.
 
C

Chris Riesbeck

Hello,

I am trying to validate a form wherein someone will enter their first
and last name, fill out the form, then electronically "sign" at the
bottom. I want to confirm that the first and last names match in the
First & Last & Signature form fields. Here is the code I wrote, but
it doesn't work because indexof is supposed to be a string. What do I
need to do to fix this?

if (document.repForm.Signature.value.indexOf(First) == -1 ||
document.repForm. Signature.value.indexOf(Last) == "-1") {
alert("Signature does not match first and last name.");
document.repForm.Signature.focus();
return false;}

If First is a field, then you need to use document.repForm.First.value,
and ditto Last.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top