Hello
I have a web form, whereby I want to allow users to only input dates in the format DD/MM/YYYY.
I've tried with the following code to show an error message if the date is not valid, however if I add something like 5/5/5, it still passes is as a valid value.
$('#DateB').blur(function(){
var s= $('#DateB').val();
var dateRegex = '^(0[1-9]|1[012])[\/\-](0[1-9]|[12][0-9]|3[01])[\/\-](19|20)\d\d$';
if(!dateRegex.match(s)){
$("#msgDOB").val("date format not valid");
$("#msgDate").css("display","block");
}else
{
$("#msgDate").css("display","none");
}
});
Anyone can pls help me fine-tune this code?