
function formError(selector,message){this.selector=selector;this.message=message;}
function FormValidator(){this.errors=new Array();this.counter=0;this.is_form_valid=true;this.textField=function(val,field_string,selector,minlength,maxlength,char_restrictions){if(val.length<1){this.errors[this.counter]=new formError(selector,"Please enter "+field_string);this.counter++;this.is_form_valid=false;return false;}
if(minlength){if(val.length<minlength){this.errors[this.counter]=new formError(selector,field_string+" is too short.");this.counter++;this.is_form_valid=false;return false;}}
if(maxlength){if(val.length>maxlength){this.errors[this.counter]=new formError(selector,field_string+" is too long.");this.counter++;this.is_form_valid=false;return false;}}
if(char_restrictions){}
return true;}
this.emailValid=function(val,selector){if(!this.textField(val,'email address',6)){this.errors[this.counter]=new formError(selector,'Please enter an e-mail address.');this.counter++;this.is_form_valid=false;return false;}
if(val.indexOf('@')<0){this.errors[this.counter]=new formError(selector,'Please enter a valid e-mail address.');this.counter++;this.is_form_valid=false;return false;}
if(val.indexOf('.')<0){this.errors[this.counter]=new formError(selector,'Please enter a valid e-mail address.');this.counter++;this.is_form_valid=false;return false;}
return true;}
this.createError=function(selector,message){this.errors[this.counter]=new formError(selector,message);this.counter++;this.is_form_valid=false;}
this.getErrors=function(){return this.errors;}}