multiple form validation using jquery validation plugin -


i have single form, having 2 buttons, , when both buttons clicked, validate differently. having trouble doing that. have following form looks this:

<form id="testform" method="post">    <input type="textarea" name="remarks" />    <input type="file" name="files[0]"/>    <button id="button1">button 1</button>    <button id="button2">button 2</button> </form> 

how use validation plugin in such way when button1 clicked, validates remarks field, button2 validates both remarks , files[0] fields? have tried using following doesn't seem work...

$("#testform").validate({             //e.preventdefault();             rules : {                 remarks: {                     required: true,                 }             },             highlight: function(element) {                 $(element).closest('.form-group').addclass('has-error');             },             unhighlight: function(element) {                 $(element).closest('.form-group').removeclass('has-error');             },             errorelement: 'span',             errorclass: 'text-danger',             errorplacement: function (error, element) {                 if (element.attr('type') == 'radio') {                     error.insertafter(element.parents('label').siblings(':last'));                 } else if (element.parents('div').hasclass('input-group')) {                     error.insertafter(element.parents('.input-group'));                 } else {                     error.insertafter(element);                 }             }         }); 


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -