aaaaAgg: {
required: function(){
var g = $("input[name=ggAgg]").val();
var m = $("input[name=mmAgg]").val();
var a = $("input[name=aaaaAgg]").val();
var d = g + '/' + m + '/' + a;
var reg = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/(19\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/(19\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/(19\d{2}))|(29\/02\/(19(0[48]|[2468][048]|[13579][26]))))$/;
var c = reg.test(d) && $("#cartaAggiuntiva").is(":checked");
console.log(c);
return ( c );
},
}
means that aaaaAgg
is required depending on the returned value of that function required: function(){..}
but it will be only run once ( and only once) the page loads, and that's that... if the function returns true, so it's required, otherwise not... I would suggest you read this addMethod()
. a demo of that kind here.