在javascript验证中输入类型日期字段问题 [英] Input type date field issue in javascript validations

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

问题描述

我有一个html 5输入日期类型datepicker字段。

通过比较数据库和当前日期的现有日期来实现客户端验证。



这里的问题是浏览器文化语言

例如exDate = 09/10/2014



当浏览器语言en-US新日期(exDate)返回正确2014年9月10日

但是如果浏览器语言en_AU(澳大利亚)将于2014年10月9日返回。

因此无法进行显示相关的弹出消息。

使用MVC4,Html 5剃须刀视图和jquery



注意:在日期选择器中需要显示日期基于文化

Iam having a html 5 input date type datepicker field.
have ti implementing client side validations by comparing with existing dates in database and current date.

Here the issue is with browser culture language
for example exDate= 09/10/2014

When the browser language en-US new Date(exDate) is returning correct Sep 10 2014
but if the browser language en_AU (australia) which is returning Oct 09 2014.
So could not able to display relevant pop up message.
Using MVC4, Html 5 razor view and jquery

Note: In date picker the date needs to display based on the culture

推荐答案

您可以使用cultureinfo从服务器中检索日期格式,并将该日期格式分配给jquery datepicker。请通过以下链接。



http://stackoverflow.com/questions/12457763/datetime-binding-from-jquery-datepicker-to-mvc-problems [ ^ ]



http:// stackoverflow.com/questions/8531247/jquery-datepickers-dateformat-h​​ow-to-integrate-with-net-current-culture-date [ ^ ]
You could retrive the date format from the server using the cultureinfo and assign that date format to the jquery datepicker. Please go through the below link.

http://stackoverflow.com/questions/12457763/datetime-binding-from-jquery-datepicker-to-mvc-problems[^]

http://stackoverflow.com/questions/8531247/jquery-datepickers-dateformat-how-to-integrate-with-net-current-culture-date[^]


这篇关于在javascript验证中输入类型日期字段问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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