compare two fileds for confirmation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was trying to get two inputs like pwd and compare just for confirmation
while working in form environment. Can somebody tell me what I need to do? I
intend to save the result in MS access dbs
Thanks
 
The form validation in Frontpage doesn't seem to allow what you want to do -
I had the same problem, and found this script below on this site:
http://javascript.internet.com

In the <form> tag, add this bit of javascript exactly as written below:

onSubmit="return checkPw(this)"


So when user clicks the submit button the script checks the two password
fields are the same, else returns an error, and asks for input again.
Insert this script below into the <body> section immediately below the body
tag, copy and paste into notepad first; then copy into the code view of your
web site.

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Carey Walker ([email protected]) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function checkPw(form) {
pw1 = form.pw1.value;
pw2 = form.pw2.value;

if (pw1 != pw2) {
alert ("\nYou did not enter the same new password twice. Please re-enter
your password.")
return false;
}
else return true;
}
// End -->
</script>
 
Thanks Mr. Murray
But what is pw1 and pw2. are they referring to the field names on the form?
 
Yes:
basically the script checks pw1 is the same as pw2 (that's what you wanted
right - a 'enter a password' and "enter password again to verify')....it can
be whatever you like - you can have it check that the person enter's their
email address twice the same if you wanted to.

pw1 and pw2 are just what the author of the script called the fieldnames.

Modify them to whatever you like, or leave them alone, and make sure that
the fields in your form are called "pw1" and "pw2" (the ones that asked for
a password, or email or whatever you want the user to enter twice.).
 
by the way, this script just checks that the data in the fields are entered
twice; it doesn't interfere with whatever means you use to write the data to
the database, because it validates those fields and makes sure they're
correct *before* submitting the data, and won't submit it until the fields
contain the same data.
 
Back
Top