I have the following form that I create with PHP:
echo '<form name="frmCalificar" method="post" action="calificar.php">';
echo '<br>Calificacion:<input type="number" name="txtCalificacion" required/><br>';
echo '<p>Observacion:</p><textarea name="txtObs" rows="5" cols="21" ></textarea><br>';
echo '<input type="submit" class="btn btn-danger" name="btnRechazar" value="Rechazar">';
echo '<input type="submit" class="btn btn-success" name="btnAceptar" value="Aceptar">';
echo '</form>';
which looks displayed as follows:
As can be seen in the code, the qualification space is required when submitting the form, but I only want it to be required when clicking on the accept button. When rejecting it, that field is not required. Is there a way to do this? When pressing the accept button, if the qualification field is blank, it asks me, but when pressing reject, the form can be sent without being forced to put something in the qualification.
note: for the 2 buttons the comment field must be saved, but without being mandatory
For your specific case, the formnovalidate attribute can be used for the submit buttons , which what it does is that if you click on that submit it does not validate the form, but of course for more complex forms where rejecting if it may require some validation will not work for you because it cancels the validation of the entire form, in those cases, you will need to do your own validation with javascript .
See if it works for you and tell me, I have done a small test locally and it seemed to go well.