JQuery Validation for Array of Input Elements

前端 未结 4 602
被撕碎了的回忆
被撕碎了的回忆 2020-12-09 06:50

I need to validate an array of input text elements (mileage): For example:


  
        

        
4条回答
  •  北海茫月
    2020-12-09 07:27

    Based on eddy answer, this function takes into count also the ignore setting.

            checkForm: function() {
                this.prepareForm();
                for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
                    var checkingElements = this.findByName( elements[i].name ).not(this.settings.ignore);
                    if (checkingElements.length !== undefined && checkingElements.length > 1) {
                        for (var cnt = 0; cnt < checkingElements.length; cnt++) {
                            this.check( checkingElements[cnt] );
                        }
                    } else {
                        this.check( elements[i] );
                    }
                }
                return this.valid();
            },
    

提交回复
热议问题