PDA

View Full Version : Double-checking an e-mail address in a form


Funky Monk
09-04-03, 03:30 PM
Hi,

I have a form on a web site. I want to be able to ask the user to re-enter their e-mail address and use Javascript to validate that the 2 addresses are the same.

I have so many users who mis-spell their e-mail addresses and consequently can't then contact them (it's for a mailing list). I've seen this on other sites but can't work out how to do it.

Thanks.

BdSBB
09-04-03, 03:42 PM
function validate(f) {

if (f.email.value != f.re_email.value) {
alert('Your emails do not match!');
return false;
}
}

<form onsubmit="javascript:validate_email(this);">
<input name="email">
<input name="re_email">
... etc. ...
</form>


like this?

pat@barelyfitz.com
09-17-03, 11:11 PM
Also take a look at the following for a user-friendly addition for email address or password checking:

Verify / Notify for Duplicate Fields (http://www.barelyfitz.com/webdesign/articles/verify-notify/)

Also keep in mind that the javascript might not work, so if you want to be extra sure that the two fields are the same, then you should check them in your back-end CGI.

In general, you should never rely on client-side processing to guarantee your data -- always check on the server where you have total control (but in this case, it might be overkill).