/ Published in: Other

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* This is the email validator observer, it can passed events such as onblur,onkeypress,onclick*/ function validateemail(event){ var element = Event.findElement(event,'input'); var str = element.value; var name = element.name; if((str.indexOf(".") > 2) && (str.indexOf("@") > 0)){ $('emailerror'+name).innerHTML=''; } else{ new Effect.Highlight('emailaddress'); if($('emailerror'+name)){ $('emailerror'+name).innerHTML='*** Still Invalid Email! ***'; } else{ } } } /* find all input elements where class = validateemail and apply validate observer*/ $$('input.validateemail').each(function(element){ Event.observe(element,'blur',validateemail,true); });
Comments
