Javascript mm / dd / yyyy日期格式函数 [英] Javascript mm/dd/yyyy Date Format Function

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

问题描述



我需要以mm / dd / yyyy格式在三个文本框中的Bitrh日期。在第一个文本框中,用户只能输入第二个用户的月份只能输入日期而在最后一个文本框中使用可以只有当用户输入月份时,他才会在填写日期后导航到日期文本框,用户自动转到年份文本框。

谢谢

Naveen Sharma

Hi,
I need Date of Bitrh in mm/dd/yyyy format in three textboxes.In first textbox user can only enter Month in second user can only enter Date and in last textbox use can only enter Year.when user enter month he will navigate to date textbox after filling date user automatically go to year textbox.
Thanks
Naveen Sharma

推荐答案

我认为解决所有问题(无论多么简单)都不值得付出努力,因为你总是可以使用更充足的 DateTimePicker 。请参阅:

http://weblogs.asp.net/hajan/archive/2010/07/15/integration-of-jquery-datetimepicker-in-asp-net-website-part-1.aspx [ ^ ]。



-SA
I don't think solving all that problems (however simple) worth the effort, as you can always use much more adequate DateTimePicker. Please see:
http://weblogs.asp.net/hajan/archive/2010/07/15/integration-of-jquery-datetimepicker-in-asp-net-website-part-1.aspx[^].

—SA


只需捕获三个文本框的Blur事件,并检查三个框中每个框中的值是否有效。



例如
Just catch the Blur event for the three textboxes and check that the values are valid within each of the three boxes.

E.g.
<input type="text" id="1" value="test" onBlur="javascript:Validate()();">
function Validate(){
 if text > 31 {alert (Invalid Date);}.
}



您还需要处理闰年验证和月份验证(30,31天等)。

所以使用像 http://www.the-art-of-web这样的东西可能会有用.com / javascript / validate-date / [ ^ ]。您可以在输入所有三个日期元素后执行此操作。


You will need to handle leap year validaation and month validations as well (30, 31 days etc).
So it might be useful to use something like http://www.the-art-of-web.com/javascript/validate-date/[^]. You can do this when all the three date elements have been entered.


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

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