473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

trouble with indexof for form value

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
2 2943
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
2
by: Bernard Bourée | last post by:
I have a class named "Variable" with 2 properties "Name" and "Value" and the following class to handle a collection of Variable: Public Class ColVariables Inherits CollectionBase Default Public...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
11
by: Al | last post by:
This statement returns a -1, indicating "not found": Find1 = Array.IndexOf(FilesArray, "sa001") But IndexOf on a specific item in that array returns a value of 26: Find1 =...
14
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
0
by: Maxx57 | last post by:
C# VS.Net 1.1 (2003) - trouble with using IE proxy server settings I've got a program that detects if it can connect to a webservice. It sends a System.Net.WebRequest and then checks the...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.