I have my html page with a form that, onsubmit call a javascript function for check some value:
html:
<form onsubmit="isempty();" role="form">
isempty():
function isempty() {
var r_1;
var r_2;
var r_3;
r_1 = document.getElementById("t_select");
r_2 = document.getElementById("t_descr");
r_3 = document.getElementById("t_terms");
if((r_1.value == "Please select...") || (r_2.value == "") || (r_3.checked == false)) {
alert("Please fill in all the form fields including the terms of use to proceed with the publication");
return false;
} else {
//OK
}
}
All works done, the only problem is that in case of check fail, page display alert then reload, cleaning all preview inserted data. How can I display alert in case of failure and then freeze page (no reload)?
So many thanks in advance