我正在使用JQuery验证插件。
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.js"></script>
今天,我遇到了一个需要validated fields with the same name的问题,比如:<input type="text" name="foo[]" value="" /> --问题是插件只会验证第一个字段。我知道原因是因为我认为插件需要独特的名字。是
我有一个相对简单的表单,需要有条件地提交,如果HTML5验证没有通过,则显示验证消息。
我走在使用jQuery验证的道路上,这似乎很好,但我所需要的只是
if( $('#myForm').valid()) {...}
不过,jQuery验证似乎决心将错误消息放入DOM中,并阻止浏览器本地消息,这是我不想要的。我不知道我是瞎子还是哑巴(可能两者兼而有之),但我想不出如何阻止这种行为。
这就是我现在拥有的:
// call validate to set the form up for validation
$(this).closest('form').valid
目前,我有一个文件,我命名为JQuery.ext.js,我包括在我的所有网页。在这个文件中,我有许多功能,可以执行以下操作:
(function($) {
/**
* Checks to see if a container is empty. Returns true if it is empty
* @return bool
*/
$.fn.isEmptyContainer = function() {
//If there are no children inside the element then it is empt