Click to See Complete Forum and Search --> : E-mail validation
Cesark
11-11-2003, 06:17 AM
How can I modify this e-mail validation function so that check the number of characters situated after [.], only allows two characters minimum and four characters maximum as a domain, and only allows one [.] between the last character and the domain? (Delete the ‘com, net, org, fr,..’ validation)
Thanks,
Cesar
Charles
11-11-2003, 06:34 AM
The following checks the field against the formal definition of a valid e-mail address...
<!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="">
<div>
<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>
</div>
</form>
Cesark
11-11-2003, 09:24 AM
Thank you Charles,
But :confused:, where I have to write your script in my function attached? I do not understand what exactly your script do, I have tried to execute like an ‘htm’ document and when I click the button nothing happens, it only erase the text inside the field.
Cesark
11-12-2003, 09:37 AM
Well, now runs, I forgot to write one name for the function and one action for the form (I have attached my code). Anyway the form do strange things, like always does not accept the first e-mail you wrote and the second time you write the same e-mail this is accepted. Any thing your write twice it does the same, is not necessary you write an e-mail.
But it does not matter, I am going to continue searching out in my manuals and with other questions in this forum and others.
Thanks,
Cesar