Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

form validation jquery input array

$("#passenger_info").validate({
  errorPlacement: $.noop,
  ignore: ".ignore_val",
  rules: {},

  invalidHandler: function (form, validator) {
    var errors = validator.numberOfInvalids();
    if (errors) {
      validator.errorList[0].element.focus();
    }
    $("input.first-name").each(function () {
      if ($(this).val() == "" && $(this).val().length < 1) {
        $(this).addClass("error");
      } else {
        $(this).removeClass("error");
      }
    });
  },

  submitHandler: function (form) {
    var isValid = true;
    $("input.first-name").each(function () {
      if ($(this).val() == "" && $(this).val().length < 1) {
        $(this).addClass("error");
        isValid = false;
      } else {
        $(this).removeClass("error");
      }
    });

    if (isValid) {
      form.submit();
    }
  },
});
Comment

array validation in jquery

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

array validation in jquery

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

PREVIOUS NEXT
Code Example
Javascript :: solcjs 
Javascript :: how to use axios 
Javascript :: reverse string javascript 
Javascript :: reset event listener javascript 
Javascript :: promises chaining 
Javascript :: jquery properly work 
Javascript :: sequelize date format 
Javascript :: jquery dom traversal parent 
Javascript :: passing json as datasource to jasper report library 
Javascript :: how to decode jwt token in react 
Javascript :: accessing json data 
Javascript :: date match mongodb 
Javascript :: merge binary tree 
Javascript :: check property exists in object javascript 
Javascript :: how to redirect to another page without writing javascript 
Javascript :: elif in js 
Javascript :: form- text area react 
Javascript :: inline style to change background color javascript 
Javascript :: routerlink not working 
Javascript :: download file from api response 
Javascript :: javascript add field to array 
Javascript :: es6 foreach dom element 
Javascript :: dropdown hide 
Javascript :: online password generator 
Javascript :: es6 spread assign nested object 
Javascript :: javascript closest parent 
Javascript :: shopify routes 
Javascript :: make custom draggable in react 
Javascript :: map function in js 
Javascript :: function as object 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =