mercredi 15 avril 2015

Ignore required inputs in a form if a button (input type of submit) is clicked

I have two buttons for one form (two input types of submit).


One button requires more inputs than the other button.


How am I able to press the button that doesn't require certain inputs without being stopped because it is saying that there are required inputs that are empty (but they are actually only required for the other button).


Thank you, any help is much appreciated! Al


EDIT CODE: I wrote a small piece of code that reflects my question. Let's assume when pressing the firstButton you require all inputs. When you press the secondButton you require only the second input. How would I ignore the first required input in that case?



<form id="formID" action="processForm.php" method="post">
<input id="firstInput" name="input1" placeholder="Amount" required>
<input id="secondInput" name="input2" placeholder="Amount2" required>
<input type="submit" value="firstInput" alt="firstButton">
<input type="submit" value="secondInput" alt="secondButton">
</form>


I wrote a small piece of code that reflects my question.


Aucun commentaire:

Enregistrer un commentaire