| Current Path : /var/www/html/llcfapp/public/http/validation/ |
| Current File : /var/www/html/llcfapp/public/http/validation/cutomervalidators.js |
jQuery.validator.addMethod("cnicPk", function(value, element) {
if(value != ""){
cnic_no_regex = /^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$/;
return (cnic_no_regex.test(value)) ? true : false;
}else{
return true;
}
}, "* Invalid CNIC format");
jQuery.validator.addMethod("cellPk", function(value, element) {
cell_num_pk = /^((\+92)?(0092)?(92)?(0)?)(3)([0-9]{9})$/gm;
return (cell_num_pk.test(value)) ? true : false;
}, "* Invalid Cell number");
jQuery.validator.addMethod("cell_num_int", function(value, element) {
cell_num_int = /^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/gm;
general_cell_num = /\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$/;
return (cell_num_int.test(value) || value.trim() == "" || general_cell_num.test(value)) ? true : false;
}, "* Invalid Cell number");
jQuery.validator.addMethod("notEqualToValue", function(value, element, arg){
return arg !== value;
}, "Value must not equal arg.");
$.validator.addMethod( "notEqualToInput", function( value, element, param ) {
return this.optional( element ) || !$.validator.methods.equalTo.call( this, value, element, param );
}, "Please enter a different value, values must not be the same." );
jQuery.validator.addMethod("greaterThan",
function(value, element, params) {
if(value == ''){return true;}
if (!/Invalid|NaN/.test(new Date(value)) && !/Invalid|NaN/.test(new Date(params))) {
return new Date(value) > new Date(params);
}else if(/Invalid|NaN/.test(new Date(params))){
return new Date(value) > new Date($(params).val());
}
return isNaN(value) && isNaN($(params).val())
|| (Number(value) > Number($(params).val()));
},'Must be greater than {0}.');
jQuery.validator.addMethod("lessThan",
function(value, element, params) {
if(value == ''){return true;}
if (!/Invalid|NaN/.test(new Date(value)) && !/Invalid|NaN/.test(new Date(params))) {
return new Date(value) < new Date(params);
}else if(/Invalid|NaN/.test(new Date(params))){
return new Date(value) > new Date($(params).val());
}
return isNaN(value) && isNaN($(params).val())
|| (Number(value) < Number($(params).val()));
},'Must be lesser than {0}.');