emailvalidator.lzx
<library>
<include href="basevalidator.lzx"/>
<class name="emailvalidator" extends="basevalidator" errorstring="Not a valid e-mail address">
<attribute name="trim" type="boolean" value="true
"/>
<attribute name="missingatmarkErrorstring" type="string" value="Missing the @ character in your email address.
"/>
<attribute name="toomanyatmarkErrorstring" type="string" value="Too many @ characters in your email address.
"/>
<attribute name="missingperiodErrorstring" type="string" value="The domain in your email address is missing a period.
"/>
<attribute name="incorrectlydomainErrorstring" type="string" value="The domain in your email address is incorrectly formatted.
"/>
<method name="doValidation" args="val">
var valtext = getValueText(val);
if(required && valtext.length < 1){
this.setErrorstring(this.requiredErrorstring);
return false;
}
if(valtext != ""){
if(valtext.indexOf("@") < 0){
this.setErrorstring(this.missingatmarkErrorstring);
return false;
}
var splitedvaltext = valtext.split("@");
if(splitedvaltext.length != 2){
this.setErrorstring(this.toomanyatmarkErrorstring);
return false;
}
if(splitedvaltext[1].indexOf(".") < 0){
this.setErrorstring(this.missingperiodErrorstring);
return false;
}
var spliteddomaintext = splitedvaltext[1].split(".")
for(var j = 0; j < spliteddomaintext.length; j ++){
if(spliteddomaintext[j] == ""){
this.setErrorstring(this.incorrectlydomainErrorstring);
return false;
}
}
}
this.setErrorstring("");
return true;
</method>
</class>
</library>
Cross References
Includes
Classes