在chrome和其他浏览器中验证日期。 [英] Validating a date in chrome and other browsers.

查看:139
本文介绍了在chrome和其他浏览器中验证日期。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想验证一个日期,所以我在asp.net 2012中将文本框模式从单个更改为日期它在chrome中工作得非常好,但是,它在IE和Firefox中不起作用。



确保在我添加的IE,Firefox和其他浏览器中输入有效日期



 <   asp:RegularExpressionValidator     ID   =  dateValRegex     runat   = < span class =code-keyword> server    ControlToValidate   =  TxtDOB    ErrorMessage   = 请输入格式为有效的日期(mm / dd / yyyy)    ValidationExpression   =  ^(0 [1-9] | 1 [012]) [ -  /.](0[1-9]|[12][0-9]|3[01])[- /。](19 | 20)\d\d $ < span class =code-keyword>>  <   / asp:RegularExpressionValidator  < span class =code-keyword>>  





它在IE中运行良好,Firefox在输入日期时效果良好但是当我在chrome中输入有效日期时,我收到验证错误消息。



是否有所有浏览器的验证?



我尝试过:



< asp:RegularExpressionValidator ID =dateValRegexrunat =server ControlToValidate =TxtDOBErrorMessage =请输入格式的有效日期(mm / dd / yyyy)ValidationExpression =^(0 [1-9] | 1 [012])[ - /。](0 [1] -9] | [12] [0-9] | 3 [01])[ - /.](19|20)\d\d$\">

解决方案
> < / asp: RegularExpressionValidator >





它在IE中运行良好,和Firefox在输入日期时但是当我在chrome中输入有效日期时我收到验证错误消息。



是否有所有浏览器的验证?



我尝试过:



< asp:RegularExpressionValidator ID =dateValRegex runat =serverControlToValidate =TxtDOBErrorMessage =请输入格式的有效日期(mm / dd / yyyy)ValidationExpression =^(0 [1-9] | 1 [012])[ - / 。](0 [1-9] | [12] [0-9] | 3 [01])[ - /。](19 | 20)\d\d


>

I wanted to validate a date, so i change the the textbox mode from "single" to "date" in asp.net 2012 it worked wonderful in chrome, however, it did not work in IE and firefox.

to make sure that a valid date is entered in IE, firefox and other browsers I added

<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>



it worked fine in IE, and Firefox when entering the date however when I enter a valid date in chrome I am getting the validation error message.

is there are validation for all browsers?

What I have tried:

<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>



it worked fine in IE, and Firefox when entering the date however when I enter a valid date in chrome I am getting the validation error message.

is there are validation for all browsers?

What I have tried:

<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


">


这篇关于在chrome和其他浏览器中验证日期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆