javascript - jquery form required on specific submit button -



javascript - jquery form required on specific submit button -

i have 1 <form> 2 submit buttons. want set title required on 1 submit button, not other one. right works on 1 dont need.

button @ end of form , required works:

<button type="submit" id="submit" class="btn btn-primary">submit</button>

button in middle of form , required not work:

<button type="submit" id="submitformat" class="btn">add format</button>

js:

$("#submitformat").click(function( event ) { $("#required").prop('required',true); } required field: <input type="text" id="required" name="title"/>

you need remove required property when utilize other button:

$("#submit").click(function() { $("#required").removeprop('required'); });

otherwise may still have required property set when clicked #submitformat button.

javascript jquery

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -