I want to block the submit of a form in this condition:
1) Without JQuery;
2) With an input type="submit" (instead of type="button"), because it's the only way (i think) to submit form with Enter Key
Here's my code:
<form name="form_ricerca" action="trova_hotels.htm" id="top_form_ricerca" method="post">
<fieldset style="margin: 10px;text-align: center;">
<input id="top_ric_strutt" type="text" name="ricerca" size="40"
<input onclick="return top_controlla_ricerca();" >
</fieldset>
</form>
and this is the function:
function top_controlla_ricerca() {
var nome_codice = document.getElementById("top_ric_strutt").value;
SOME_CODE
if (SOME_CONDITIONS) {
document.getElementById("top_form_ricerca").submit();
return true;
} else {
alert('MY_ALERT');
return false;
}
}