Free web development scripts for the webmasterDevelopment Scripts

 Site Navigation
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 8 users online
 o Most users online: 67
 o Home
  o Javascripts
   o Forms Manipulation
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Designer Baby Clothes
 o Advertise Here Make Money
 o OxyScripts
 o designplace
 o Wedding Vendor Directory
 o Open Source Design
 o devnet
 o Free Wedding Websites

Compare two (2) form values and see if they're the same (Rated 0)

Description:

In this example it simply displays an alert, whereas in reality you'd want to only display to the alert if there is an error.

Code starts here


<script>
function compare(valOne, valTwo)
{
if (valOne != valTwo)
{
alert("Your passwords must match");
return false;
}
else
{
alert("Your passwords match - well done");
return false;
/*Comment out the two line above and uncomment the one below to actually submit the form*/
//return true;
}
</script>

<form action="page2.html" name="myForm">
<input type="text" name="passwordOne"><br><br>
<input type="text" name="passwordTwo"><br><br>
<input type="submit" onClick="JavaScript: return compare(myForm.passwordOne.value,myForm.passwordTwo.value); return false;">
</form>


Submitted by MattK on 06-01-2006 8:39


Rate This Script

User Contributed Comments

Registered Members login
© Copyright 2003 - Devscripts.net