View Full Version : field comparison in javascript
aqeel
12-21-2009, 05:06 PM
HI
Im using two field in HTML form 'emai' and 'ConfirmEmail'
I want that when user submit the form both field values are get checked that user entered the same value in both fields .... How can i compare thsese two values using javascript......
Feel free to email me from my profile.
jscheuer1
12-21-2009, 05:51 PM
You really don't want to publish your email address in an open forum. You will get tons of spam.
To answer your question, you need an onsubmit event for your form. About the simplest would be something like:
<form action="whatever"
onsubmit="if(this.elements.email.value === this.elements.ConfirmEmail.value){
return true;
}alert('Email and Confirm Email fields don\'t match');return false;">
Insert the highlighted into your form tag.
Notes: I used 'email' for the name of the email input. In your post you have it as 'emai'. But I'm thinking that was a typo. Whatever it's name is though, it should match up. Make sure that it does.
Also, this will be of no use if the user has javascript disabled or unavailable. If you are processing the results of this form on the server side, a server side fall back should also be used.
aqeel
12-22-2009, 03:21 AM
thanx alot ... that was email..
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.