jquery validate date of birth format dd-mm-yy

Sam Deering

jquery validation for dob to specific format ie dd-mm-yy

 
$.validator.addMethod("dateFormat",
    function(value, element) {
        return value.match(/^dd?-dd?-dd$/);
    },
    "Please enter a date in the format dd-mm-yyyy.");
And then on your form add:
$('#myForm')
    .validate({
        rules : {
            myDate : {
                dateFormat: true
            }
        }
    });

Win an Annual Membership to Learnable,

SitePoint's Learning Platform

  • wilson

    nice