Thursday, 2 February 2012

JQuery check a valid Date

function IsValidDate(val) {

    var RetVal = false;
    var ValidDate;

    try {

        ValidDate = $.datepicker.parseDate("dd/mm/yy", ReplaceAll(val, ".", "/"));
        RetVal = true;

    }
    catch (ex) {
    }

    return RetVal;
}

Ex:

IsValidDate(“25.02.2010”);    //true

IsValidDate(“25/02/2010”);    //true

IsValidDate(“25022010”);      //false

No comments:

Post a Comment