Click to See Complete Forum and Search --> : Forms and email address


pj&b
09-05-2003, 12:17 PM
I've created a form that works fine.
I have asked the customer to enter there email address. Than I want them to enter there email address again to confirm that they have entered it correctly. The same as this sites reg page does. I need the code to back that up. Any help?;) ;)

Charles
09-05-2003, 12:27 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>

<style type="text/css">
<!--
label {display:block; margin:1em 0em}
input {display:block}
-->
</style>

<script type="text/javascript">
<!--
String.prototype.isEmailAddress = function () {return this.match(/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/)}
// -->
</script>

<form action="" onsubmit="if (this.first.value != this.second.value) {alert('There seems to be a mistake.'); this.reset(); return false}">
<div>
<label>Email Address<input type="text" name="first" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid e-mail address.'); this.value = ''; this.focus()}"></label>
<label>Again<input type="text" name="second" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid e-mail address.'); this.value = ''; this.focus()}"</label>
<button type="submit">Submit</button>
</div>
</form>

Jona
09-05-2003, 12:31 PM
You'll want this to be server-side tested as well, because it can be "gotten through" if only client-side validated.


function validate_email(argA, argB){
if(argA == argB){return true;}
return false;}
</script></head>
<body>
<form action="script.php" onsubmit="validate_email(this.form.email.value, this.form.email_confirm.value);">
<div>
<input type="text" name="email" value="Email"><br>
<input type="text" name="email_confirm" value="Confirm Email">
</div></form>
</body></html>


[J]ona