Jquery validation two inputs one is required listener -


im looking validate 2 input fields. 1 required. code have works, trying validate after 1 of fields filled in.

if i tab on field error goes away. rather error go away after user fills in info on said field.

code:

$('#talent_form').validate({   ignore:"",   onfocusout: false,   rules: {     "talent_category":      "required",     "talent_description":   "required",     "city":                 "required",     "first-name":           "required",     "last-name":            "required",     "email":                { required: true, validemail: true },     "uploadedfile":             {       required: function(element) {         return $("#text-link").val() == 0;       }     },     "text-link":            {       required: function(element) {         return $("#uploadedfile").val() == 0;        }     }   },   submithandler : function(form) {     form.submit();         $("#talent_submit").html('submitting...');     sendeventtoga('talent_submitted');   }  }); 

form:

<form enctype="multipart/form-data" id="talent_form" class="validate" action="uploader3.php" method="post">    <div class="upload-fields">     <div class="fileupload home-cta btn btn-primary">       <span>upload</span>         <input type="file" name="uploadedfile" id="uploadedfile" class="upload"  multipart/>       </div>     <div class="file-link">       <input type="text" class="file-upload" name="text-link" id="text-link" placeholder="link">     </div>   </div> </form> 

problem:

enter image description here

the 2 fields looking have done between uploadedfile && text-link. reiterate, if user chooses enter text rather file, error still shows on file input field.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -