Click to See Complete Forum and Search --> : Validating emails address and loops


bogart
08-10-2004, 05:59 PM
Would some one be so kind and help am totaly new to this and had to miss a class due to work and am lost as to where to start

I need a script that validates an email address, must contain one @, contains at least one dot after the @,one character before the @,has at least two characters after the dot and does not contain spaces.............as well as preloads 10 different images using a loop

thanks to everyone and anyone that can help me

Charles
08-10-2004, 06:24 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>

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

</head>
<body>
<form action="someScript.pl">
<fieldset>
<label>E-mail address<input onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid e-mail address.'); this.value = ''; this.focus()}" type="text"></label>
<button type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>

1) Always be certain that your page passes the HTML validator at http://validator.w3.org/.

2) If you want that to look a little better, use CSS (http://www.w3.org/TR/REC-CSS2/).

3) That's a bit more robust than you'll need for your homework. See http://devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/regexp.html for how to adjust the pattern matching.

bogart
08-10-2004, 07:21 PM
thank you for your help,,do you know how to preload using loops,,,I know how to preload in the header,re-images,,rollovers etc, but using loops,,I guess I can not miss one single class ARRGGHH!!

but someone has to pay the bills