Hello,
I am creating a site with classic .net 4.0 and jquery 1.8.3
My problem is: I have 2 textbox with validators (number and date). The validators should work when I digit the characters.
This validator works for the first textbox:
var txtTestID = ‘#’ + ‘<%=txtTest.ClientID %>’;
var reg = /[^0-9]/g;
$(txtTestID).bind(‘input propertychange’, function () {
$(this).val($(this).val().replace(reg, ”));
});
But ... when I have to validate the date doesn't work:
var txtDataRicezioneDa = ‘#’ + ‘<%=txtDataTest.ClientID %>’;
var regDate = new RegExp(“/(^(((0[1-9]|1[0-9]|2[0-8])[\/](0[1-9]|1[012]))|((29|30|31)[\/](0[13578]|1[02]))|((29|30)[\/](0[4,6,9]|11)))[\/](19|[2-9][0-9])\d\d$)|(^29[\/]02[\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)/g”);
$(txtDataTest).bind(‘input propertychange’, function () {
$(this).val($(this).val().replace(regDate, ”));
});
the date I need is the following: dd / mm / yyyy
Do you know how can I fix it?
Thanks in advance for your answer.