<!--修改validate根据ID验证  -->
<script type="text/javascript">
if ($.validator) {
    $.validator.prototype.elements = function () {
        var validator = this,
          rulesCache = {};

        // select all valid inputs inside the form (no submit or reset buttons)
        return $(this.currentForm)
        .find("input, select, textarea")
        .not(":submit, :reset, :image, [disabled]")
        .not(this.settings.ignore)
        .filter(function () {
            if (!this.name && validator.settings.debug && window.console) {
                console.error("%o has no name assigned", this);
            }
            //注释这行代码
            // select only the first element for each name, and only those with rules specified
            //if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
            //    return false;
            //}
            rulesCache[this.name] = true;
            return true;
        });
    }
}

</script>


//当有多个input标签name值相同时,会发生validate只会验证第一个输入框

//直接将此代码copy至你要更改验证方式的页面,将validate验证的方式更改为根据ID验证即可

 

相关文章:

  • 2022-02-03
  • 2021-07-14
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2022-12-23
  • 2022-02-08
  • 2021-06-19
  • 2021-05-17
  • 2022-12-23
  • 2023-02-23
  • 2021-10-03
相关资源
相似解决方案