Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Validation

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
0
0
US
How can I validate an e-mail address from a form? What I want is a simple popup asking that it be entered again and then compared with what has already been entered to see if it's the same. I would prefer to load the JavaScript code from an external file to minimize the JavaScript code that is in the html document itself. I know how to load in external code, but not how to actually write and impliment it! How can I do this?

The form tag is simply:
[tt]<input type=&quot;text&quot; name=&quot;E-Mail&quot; size=40 maxlength=60>[/tt]
Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Thanks, This JavaScript is very nice and sophisticated but is not what I was looking to do. I don't care so much if the e-mail address is valid or not (I know that doesn't make sense) but only that the person can type it twice the same way. I do not have the option of rewriting the Perl script to which the form is being submitted so I want a popup when they submit the form that asks them to type the address again and then compare that to the one they typed in the orogonal form. Right or wrong, if it's typed the same both times, I want the form to then submit the form normally.
Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Here's a real quick example of what I think you're wanting to do:
Code:
<html>
<head>
<script language=&quot;javascript&quot;>
function checkemail() {
email1=document.forms[0].email1.value
email2=prompt('Please enter your e-mail address again.',&quot;&quot;)
if (email1!=email2) {
alert(&quot;E-mail addresses do not match.&quot;)
return false
}
else {
return true
}
}
</script>
</head>
<body>
<form onsubmit=&quot;return checkemail()&quot;>
Email: <input type=&quot;text&quot; name=&quot;email1&quot; /> 
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top