|
E-mail Address Validation
| Language: |
JavaScript |
Unrated
Rated by 0 Users
1 Star = Horrible 5 Stars = Perfect
Rate Code Now
|
| Posted By: |
Blake |
| Author Website: |
Differences between ASP and PHP |
| Posted On: |
8/29/2007 |
| Code Views: |
541 |
This is a simple function that will help validate an email address. Normally it is used with the onBlur portion of an input...
|
function emailvalidate(inEmail1) { if (inEmail1.value.length > ) { if ((inEmail1.value.lastIndexOf(".") < inEmail1.value.indexOf("@")+3 || inEmail1.value.lastIndexOf(".") > inEmail1.value.length-3 || inEmail1.value.indexOf("@") < 1) || inEmail1.value.indexOf("@") != inEmail1.value.lastIndexOf("@")) { alert("Email Validation Failed"); } } }
// to call this... put onBlur="emailvalidate(this);" into the email field // of your input form... // Example: // <input type="text" name="email" onBlur="emailvalidate(this);">
View code in Textarea
This code has not been tested by Your WebCode. Use it at your own risk.
Please report any copyright violations.
|
|