简体   繁体   中英

validator is undefined when using jquery.validate with jquery.uploadfile

I'm trying to use both jquery.validate and jquery.uploadfile in the same page which give me this error :

TypeError: validator is undefined


if ( validator.settings.rules ) {

and If I don't include jquery.uploadfile there is no problem.How should I use both in the same page?

Thanks

I think your problem is you need to specify what element you're looking at. See link http://jqueryvalidation.org/validate/

It could also be as simple as you are just missing the "$" so $.validator because you are including that new script, the existing may be getting overwritten.

Example:

 $(".selector").validate({
    submitHandler: function(form) {
     // do other things for a valid form
     form.submit();
    }
 });

Another Example: https://elnibs.wordpress.com/2013/10/22/jquery-validation-issue-cannot-read-property-settings-of-undefined/

 var validator = $.data(this[0], 'validator');
    if ( validator ) {
        return validator;
    }

    // Add novalidate tag if HTML5.
    this.attr('novalidate', 'novalidate');

   //HERE it is creating a new one using the constructor   
    validator = new $.validator( options, this[0] );
    $.data(this[0], 'validator', validator);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM