Prevent focus on field when it fails validation

后端 未结 4 1732
醉梦人生
醉梦人生 2021-01-12 14:14

I often use this jQuery validation plugin to validate forms and it works great. Really pleased with it, but when you press Submit on a form it automatically puts focus on th

相关标签:
4条回答
  • 2021-01-12 14:50
    1. Go to your jQuery validate file file (http://jquery.bassistance.de/validate/jquery.validate.js)
    2. Use Control and F to find
    3. Remove .focus() on line 431.
    0 讨论(0)
  • 2021-01-12 15:09
    $('#frmTableDate').validationEngine({ focusFirstField: false });
    

    in case we are using Validation Engine plugin to validate

    0 讨论(0)
  • 2021-01-12 15:13

    Use the focusInvalid option and set it to false :

    $("#abc").validate({
      focusInvalid: false
    });
    

    Working example here and Documentation here (options tab)

    0 讨论(0)
  • 2021-01-12 15:15
    $("#myform").validate({
    onfocusout: false,
    invalidHandler: function(form, validator) {
        var errors = validator.numberOfInvalids();
        if (errors) {                    
            validator.errorList[0].element.focus();
        }
    } 
    });
    
    0 讨论(0)
提交回复
热议问题