我有3个输入字段-日,月和年。我需要将这些值字符串化为日期格式,并包括对已输入到这些字段中的无效日期的验证。
我目前具有以下验证。
<input type="number" class="form-control" minlength="2" maxlength="2" name="dd" placeholder="DD">
<input type="number" class="form-control" minlength="2" maxlength="2" name="mm" placeholder="MM">
<input type="number" class="form-control" minlength="4" maxlength="4" name="yyyy" placeholder="YYYY">
$("#subscribe").validate({
rules: {
dd: "required",
mm: "required",
yyyy: "required"
},
groups: {
DateofBirth: "dd mm yyyy"
},
errorPlacement: function(error, element) {
if (element.attr("name") == "dd" || element.attr("name") == "mm" || element.attr("name") == "yyyy")
error.insertAfter("#PersonBirthdate");
else
error.insertAfter(element);
}
});