<asp:TextBox runat="server" ID="txtAppDOB" placeholder="mm/dd/yyyy" MaxLength="10" Width="120px" onkeyup="return fnDateMask(event,this);" TabIndex="8" onkeypress="return isNumber(event)"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqDOBApp" runat="server" ControlToValidate="txtAppDOB" EnableViewState="True" ErrorMessage="Required" ValidationGroup="valApp" SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regDOBApp" runat="server" ControlToValidate="txtAppDOB" CssClass="error-message" ErrorMessage="(MM/DD/YYYY)" ValidationExpression="(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$" ValidationGroup="valApp"></asp:RegularExpressionValidator>
Javascript : fnDateMask
function fnDateMask(event,control) {
var KeyID = event.keyCode;
if (KeyID != 8)
{
var s = new String(control.value);
if (s.length == 2 || s.length == 5) {
control.value = s + "/";
}
}
}
function isNumber(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
else
return true;
}
<asp:RequiredFieldValidator ID="reqDOBApp" runat="server" ControlToValidate="txtAppDOB" EnableViewState="True" ErrorMessage="Required" ValidationGroup="valApp" SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regDOBApp" runat="server" ControlToValidate="txtAppDOB" CssClass="error-message" ErrorMessage="(MM/DD/YYYY)" ValidationExpression="(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$" ValidationGroup="valApp"></asp:RegularExpressionValidator>
Javascript : fnDateMask
function fnDateMask(event,control) {
var KeyID = event.keyCode;
if (KeyID != 8)
{
var s = new String(control.value);
if (s.length == 2 || s.length == 5) {
control.value = s + "/";
}
}
}
function isNumber(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
else
return true;
}
No comments:
Post a Comment