Date validation for a textbox

后端 未结 1 535
时光取名叫无心
时光取名叫无心 2021-02-10 00:50

I have been using this to take date as mm/dd/yyyy format...



        
相关标签:
1条回答
  • 2021-02-10 01:27

    You might want to use a regular expression for the date :

    <asp:RegularExpressionValidator ID="dateValRegex" runat="server" ControlToValidate="txtDob" ErrorMessage="Please Enter a valid date in the format (mm/dd/yyyy)" ValidationExpression="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator>
    

    Also, as Daniel pointed out below you will need to use this in conjunction with your other validators to fully validate the date.

    0 讨论(0)
提交回复
热议问题