function isValidDate(sText) {
var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;
return reDate.test(sText);
}
function validate1() {
var oInput1 = document.getElementById("txtdate");
if (isValidDate(oInput1.value)) {
alert("Valid");
} else {
alert("Invalid!");
}
}
I had written code for dateformat validations in javascript
and I called this function in textbox as onkeypress="return validate1(event);" but it is not firing. It is taking date as well as any data including date.
eventin your onkeypress attribute definition, do you have any errors?function validate1()tofunction validate1(e)and try again.