Ich muss das Formular nur senden, wenn alle Eingabefelder das Attribut required="required"
haben.Wie übermittele ich ein Formular nur, wenn alle erforderlichen Attr-Felder mit Bootstrap gefüllt sind?
Meine Form:
<form method="post" action="/actions.php/" data-js-validate="true" data-js-highlight-state-msg="true" data-js-show-valid-msg="true">
<input type="text" name="amount[]" required="required" placeholder="Amount" class="inputChangeVal" data-js-input-type="number" />
<input type="text" name="grade[]" required="required" placeholder="Amount" class="inputChangeVal" data-js-input-type="number" />
<button class="btn" type="submit" name="confirm" >Pay Now</button>
</form>
Ich wollte die Form nach zeigt ein Meldungsfeld einzureichen. Wie Sie sehen, ist meine Formularaktion eine andere PHP-Datei. , so dass ich das Standardverhalten verhindern und dann das Formular senden, wenn auf die Schaltfläche "Weiter" geklickt wird. Ich benutze Bootsrap für das.
Bootstrap-Modell:
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Proccess Payment</h4>
</div>
<div class="modal-body">
<p>
"Your about to make a online payment. Click 'Edit' to review the data before proceeding or click 'Continue' to confirm the details for payment."
</p>
<button class="btn btn-default" data-dismiss="modal">Edit</button>
<button class="btn btn-primary" id="continuebtn">Continue</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
und die jQuery dafür:
<script>
jQuery(document).ready(function() {
/* for boot strap model */
jQuery('#payBtn').on('click',function(e){
e.preventDefault();
jQuery('#myModal').modal('toggle');
});
jQuery('#continuebtn').on('click',function(){
jQuery('form').submit();
});
});
</script>
aber dieses sendet das aus, wenn ich Sie auf die Schaltfläche Continue
Taste. Egal, die Eingabefelder gefüllt sind oder nicht ..
Was ich will, ist die Form nur eingereicht werden, wenn die fileds required="required"
gefüllt sind ..
wie kann ich das tun?
Es lohnt sich, [form-validation] (https://css-tricks.com/form-validation-ux-html-css/) –