Here is a function to check valid date format as mentioned below :-
function IsValidDate(dtValue)
{
var dtRegex = new RegExp(/\b\d{1,2}[\/-]\d{1,2}[\/-]\d {4}\b/);
return dtRegex.test(dtValue);
}
To Use this method on any date text field below is the code example :-
$(function() {
$('.errorDiv').hide();
$('#btnTest').click(function(event){
var dtVal=$('#txtDate').val();
if(IsValidDate(dtVal)) $('.errorDiv').hide();
else
{
$('.errorDiv').show();
event.preventDefault();
}
});
});
Here 'errorDiv' is the class name assigned to the div used for displaying the error message when date validation fails.
Hope this will be of help to you.