Validator Plugin callback on Custon Methods
hi, i've this code
- $j("#form").validate({
debug: false,
ignore: ":hidden",
rules:{
edtEXP_DT:{
required: true,
dateMinor: true,
Date30day: { required: { depends: function(element){
if("<?=$DML;?>" == "MM_Insert" &&
$j("#edt<?=$newarea?>AREA").val() == "CHIAMARE PER PROPOSTA FUTURA" &&
$j("#STATUS").val() == "OPEN") return true;
else return false;
} }
},
}
}
});
The Date30day is my addMethod
- jQuery.validator.addMethod(
"Date30day",
function(value, element) {
var check=false;
var oggi=new Date();
agiorno=oggi.getDate();
amese=oggi.getMonth()+1;
aanno=oggi.getFullYear();
if(agiorno<10)agiorno='0'+agiorno;
if(amese<10)amese='0'+amese;
var data_oggi=agiorno+"/"+amese+"/"+aanno;
var days=startEndDate(data_oggi,value);
if(days < 30 ) check = false;
else check= true;
return this.optional(element) || check;
},
"Date too recent"
);
i want' return true if some variables on form are sets.
if my function return true the Data30Day became request otherwise my function return false my Data30Day addmethod return false and it's not required.