使用javascript在文本框中验证日期 [英] validate date in textbox using javascript

查看:70
本文介绍了使用javascript在文本框中验证日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出生日期textbox1



当用户在文本框中键入任何字符串时,它会检查并显示message.please类型日期,只会返回false。



假设用户输入正确的日期意味着示例25 sep 2015.它将返回。



我怎么能valiate使用cSharp。

解决方案

对于C#来说,它是微不足道的:使用 DateTime.TryParse [ ^ ](根据喜好提供用户文化信息,以便更准确地处理他的数据)。



对于Javascript,请看这里:http://www.the-art-of-web.com/javascri pt / validate-date / [ ^ ]

Date of birth textbox1

When user types the any string in textbox it would check and shows the message.please type date only it would return false.

Suppose user typed correctly date means example 25 sep 2015. it would return.

for that how can i valiate using cSharp.

解决方案

For C# it's trivial: use DateTime.TryParse[^] (and by preference supply the user Culture info so it can work with his data more accurately).

For Javascript, see here: http://www.the-art-of-web.com/javascript/validate-date/[^]


这篇关于使用javascript在文本框中验证日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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