JSFiddle - React, Tailwind, and code Playground
HTML
Form will submit on click, but not on enter key pressed, try tabbing to button and press enter ?
<br><br>
<form id="subscription_order_form" class="" method="post" action="some_url">
<button id="btn_order" type="submit">Order</button>
</form>
JavaScript
// Prevent the form to be submitted on ENTER
$('#subscription_order_form').keydown(function(e){
console.log(e.which);
if (e.which===13) e.preventDefault();
});
// Controll data
$('#btn_order').click(function(){
checkMandatoryFields();
});
// Check mandatory fields before subitting:
function checkMandatoryFields(e){
// Code for testing here
// Set "error" message and abort submission
if(msg.length > 0) {
// Do something
} else {
//submit or trigger is not recognized as functions
$('#subscription_order_form').submit(); //.trigger('submit');
}
}