/* 
 * @author: uzzal
 * @class: validator
 * @web: http://uzzal.wordpress.com
 */

var validator={show_alert:false,setAlert:function(status){this.show_alert=status;},showAlert:function(msg){if(this.show_alert){alert(msg);this.setAlert(false);}},isNull:function(str){var re=/^[ ]*$/;if(str=='null'||str.length==0||str=='undefined'||re.test(str)){this.showAlert("A Rquired Field is Null");return true;}
else{return false;}},isNumber:function(str){if(isNaN(str)){return true;}
else{this.showAlert("A Rquired Field is Not a Number");return false;}},isEmail:function(str){var re=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;if(!re.test(str)){this.showAlert("Email Field is Not a Valid Email");return false;}else{return true;}},isUrl:function(str){var re=/^https?:\/\/[^ ]+\.[^ ]+$/;if(!re.test(str)){this.showAlert("Url Field is Not a Valid Url");return false;}else{return true;}},isPasswordMatch:function(password,confirm){if(this.isNull(password)){return false;}
if(this.isNull(confirm)){return false;}
if(password==confirm){return true;}
else{this.showAlert("Password and Confirm Password Field Did Not Matched");return false;}},isInMax:function(str,max_limit){if(str.length<=max_limit){return true;}else{this.showAlert("A Field Exceeds The Maximum Character Limit");return false;}},isInMin:function(str,min_limit){if(str.length>=min_limit){return true;}else{this.showAlert("A Field Below The Mainimum Character Limit");return false;}}};