By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,252 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,252 IT Pros & Developers. It's quick & easy.

trouble with indexof for form value

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

Jul 20 '05 #2

P: n/a
je*************@yahoo.com (Jeremy) wrote in message news:<f9**************************@posting.google. com>...
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.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.