javascript - Jquery 日期规则在 Firefox 和 IE 中不起作用

标签 javascript jquery validation firefox jquery-validate

我用 jquery 日期规则渲染了普通文本。日期规则在 chrome 中工作正常但在 Firefox 和 IE 中不起作用。请看我的代码块。

<form id="myform"> <input id="datepick" type="text" name ="datepick"/><br/> <input type="submit" id="ValidateDate" /> </form>

    $("#myform").validate({
         rules: {
           datepick:{
               date:"MM/dd/yyyy" 
           }    
      },
        messages: {
           datepick:{
             date:"Give MM/dd/yyyy format"
        }
     }
  });
    $('#datepick').keyup(function () {
        $("#ValidateDate").submit();
    });
</script>

当我输入 12/3err/3001 时,它会在所有浏览器中抛出错误

当我输入 12/234/2333 时,它抛出错误 chrome 而不是在 firefox 和 IE 中。

另外我想分享一个信息。

http://jqueryvalidation.org/date-method/

在上面的链接中,jQuery 验证在 Mozilla 和 IE 浏览器中无法正常工作,即使对于普通文本框也是如此。

请在上面的 jquery 链接示例中键入 22/233/2222 值,然后您可以找到以下输出变体

在 Chrome 中:

chrome output screen shot

在 Firefox 中:

enter image description here

请帮我解决这个问题......

谢谢,

戈巴拉克里希南

最佳答案

您链接到的文档是这样说的:

This method should not be used, since it relies on the new Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

我的重点。

关于javascript - Jquery 日期规则在 Firefox 和 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34367315/

相关文章:

javascript - 居中主 div 中的三个 div

postgresql - 存储月份的数据类型或约束

c# - wpf 中的文本框验证

javascript - 删除我的 anchor 中的哈希值

javascript - ColdFusion CFC CORS 和 AJAX 帖子

javascript - 高级字符串本地化

javascript - 有没有办法为 1 个请求设置 cookie?

c++ - 在 Windows C++ 应用程序中验证输入的 UTF-8 序列

javascript - 有什么优雅的方式告诉 IE7 及以下版本的用户离开吗?

javascript - 查找与条件匹配的数组索引,然后插入另一个数组