日期格式为“dd / MM / yyyy”验证 [英] date in format "dd/MM/yyyy" validation

查看:100
本文介绍了日期格式为“dd / MM / yyyy”验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在asp.net中编程。我在TextBox中有一个日期格式为dd / MM / yyyy。

我想验证日期是否真的正确。


我使用RegularExpressionValidator

ValidationExpression =" [0-3] [0-9] / [0-1] [0-9] / [1-2] [0-9] [0- 9] [0-9]",但是用户

可以写日期31/02/2000验证员说它是正确的(每个人都知道,2月有28天或29天)。


我在考虑使用RangeValidator和Type ="日期" ;.但是如何告诉

RangeValidator,该日期格式为dd / MM / yyyy。 ?


也许这是更简单的解决方案?

我想在客户端站点拥有完全安全的验证方法..


感谢您的帮助

解决方案

< am ******* @ poczta.onet.plwrote in message

新闻:gf ********** @ news.onet.pl ...


我在ASP中编程。净。我在TextBox中的日期格式为dd / MM / yyyy。

我想验证日期是否真的正确。



首先,您的日期格式不明确。例如。以这种格式,明天的日期

将显示为12/11/2008。有些人会在11月12日看到,但是其他人(例如我们在美国的朋友)会将其视为2008年12月11日。你应该看到
总是用三个显示日期 - 数字月。


也许这是更容易的解决方案?

我想在客户端网站上有完整的安全验证方法..



到目前为止最简单的解决方案,以及永远不会允许无效日期的解决方案,

不允许用户手动输入日期。相反,使用日期

选择器。


有几十个,也许几百个可用:
http ://www.google.co.uk/search?hl = en ... icker%22& meta =

-

Mark Rae

ASP.NET MVP
http://www.markrae.net




" Mark Rae [MVP]" < ma ** @ markNOSPAMrae.netwrote in message

news:%2 ****************** @ TK2MSFTNGP05.phx.gbl ...


< am ******* @ poczta.onet.plwrote in message

news:gf ***** ***** @ news.onet.pl ...


>我在ASP.NET中编程。我在TextBox中的日期格式为dd / MM / yyyy。
我想验证日期是否真的正确。



首先,您的日期格式不明确。例如。在那种格式中,明天的'b
日期将显示为12/11/2008。有些人会看到11月12日

但是其他人(例如我们在美国的朋友)会将其视为2008年12月11日。您

应始终使用三个显示日期数字月份。



[...]

但我知道我的日期格式为dd / MM / yyyy。我做了:


< asp:TextBox ID =" txtDateFrom" runat =" server">< / asp:TextBox>

< cc1:CalendarExtender ID =" CalendarDateFrom" runat =" server"

TargetControlID =" txtDateFrom"

Format =" dd / MM / yyyy">


" imbirek8" < im ****** @ op.plwrote in message

news:gf ********** @ news.onet.pl ...
< blockquote class =post_quotes>


>>我在ASP.NET中编程。我在TextBox中的日期格式为dd / MM / yyyy。
我想验证日期是否真的正确。


首先,您的日期格式不明确。例如。以这种格式,明天的日期将显示为12/11/2008。有些人会在11月12日看到
但其他人(例如我们在美国的朋友)会将其视为2008年12月11日。您应该始终使用三位数的月份显示日期。



[...]

但我知道我的日期格式为dd / MM / yyyy。



你是系统的唯一用户......?

-

Mark Rae

ASP.NET MVP
http://www.markrae.net


Hi,

I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is realy correct.

I used RegularExpressionValidator with
ValidationExpression="[0-3][0-9]/[0-1][0-9]/[1-2][0-9][0-9][0-9]", but user
can write date "31/02/2000" and validator says that it is correct (everybody
know that Febuary has 28 or 29 days).

I was thinking of using RangeValidator with Type="Date". But how to told
RangeValidator, that date is in format "dd/MM/yyyy" ?

Maybe it is easier solution ?
I would like to have total secure validation method in client site..

Thanks for help

解决方案

<am*******@poczta.onet.plwrote in message
news:gf**********@news.onet.pl...

I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is really correct.

Firstly, your date format is ambiguous. E.g. in that format, tomorrow''s date
would appear as 12/11/2008. Some people will see that as 12 November but
others (e.g. our friends in US) will see it as 11 December 2008. You should
always display dates using a three-digit month.

Maybe it is easier solution ?
I would like to have total secure validation method in client site..

By far the easiest solution, and one which will never permit invalid dates,
is not to allow users to enter dates manually at all. Instead, use a date
picker.

There are dozens, maybe hundreds, of these available:
http://www.google.co.uk/search?hl=en...icker%22&meta=
--
Mark Rae
ASP.NET MVP
http://www.markrae.net



"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...

<am*******@poczta.onet.plwrote in message
news:gf**********@news.onet.pl...

>I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is really correct.


Firstly, your date format is ambiguous. E.g. in that format, tomorrow''s
date would appear as 12/11/2008. Some people will see that as 12 November
but others (e.g. our friends in US) will see it as 11 December 2008. You
should always display dates using a three-digit month.

[...]
But I know that my date is in format "dd/MM/yyyy". I did:

<asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarDateFrom" runat="server"
TargetControlID="txtDateFrom"
Format="dd/MM/yyyy">


"imbirek8" <im******@op.plwrote in message
news:gf**********@news.onet.pl...

>>I program in ASP.NET. I have a date in TextBox in format "dd/MM/yyyy".
I would like to validate if the date is really correct.


Firstly, your date format is ambiguous. E.g. in that format, tomorrow''s
date would appear as 12/11/2008. Some people will see that as 12 November
but others (e.g. our friends in US) will see it as 11 December 2008. You
should always display dates using a three-digit month.


[...]
But I know that my date is in format "dd/MM/yyyy".

Are you the only user of the system...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


这篇关于日期格式为“dd / MM / yyyy”验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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