Jump to content

How can I check to see if two values in a form are the same?


Sprout

Recommended Posts

I just want to create a simple password check like most sites have, making sure you didn't have a typo when originally registering your password.

 

So essentially what I have is <input type="text" name="pass1"> and <input type="text" name="pass2"> and I'd like to rig something up on the form processing page that checks to make sure pass1 is equal to pass2 otherwise it returns an error.

 

Any help?

The form will have to be submitted in order for PHP to check the values. However using javascript you can control what happens with the form, such as disable the submit button if the passwords do not match and/or display an error message.

 

You'll want to look into javascript form validation. Here is a quick tutorial

http://www.w3schools.com/js/js_form_validation.asp

 

You can however use a javascript framework such as jQuery for form validation

http://yensdesign.com/2009/01/how-validate-forms-both-sides-using-php-jquery/

  Quote

The form will have to be submitted in order for PHP to check the values. However using javascript you can control what happens with the form, such as disable the submit button if the passwords do not match and/or display an error message.

 

You'll want to look into javascript form validation. Here is a quick tutorial

http://www.w3schools.com/js/js_form_validation.asp

 

You can however use a javascript framework such as jQuery for form validation

http://yensdesign.com/2009/01/how-validate-forms-both-sides-using-php-jquery/

Exactly what I needed, thank you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.