To validate the email format, check the textbox value across the regular expression value. The javascript code and corresponding html code are:
Script :
var efmt=/^\w+((-\w+)(\.\w+))*\@[A-Za-z0-9]+((\.-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; function checkEmailFormat(field,msg) { var ctrl=document.getElementById(field); if((!efmt.test(ctrl.value)) && ctrl.value!=”) { alert(msg); ctrl.focus(); } }
Add the following code into the Body tag.
Html Code :
<input type=”Text” onblur=”checkEmailFormat(’Txtemail’,'Please enter a valid email address, like sample@yahoo.com’);” id=”Txtemail” >;
Popularity: 5% [?]

November 3rd, 2008
admin
Posted in
Tags: 
