onClick=validateForm()
it shows alert if it is blank but it goes to next page("action=some.php") so any idea how to be on same page after alert?
function validateForm() {
var x = document.forms["uploadForm"]["userImage"].value;
if (x == "") {
alert("Choose the file !!!!!");
return false;
}
var p = document.forms["uploadForm"]["Start_Date"].value;
var q = document.forms["uploadForm"]["End_Date"].value;
if (p == "" && q=="") {
alert("Select the date !!!!!");
return false;
}
var radio = document.forms["uploadForm"]["radio"].value;
if (radio == "") {
alert("Select the Radio !!!!!");
return false;
}
}
I used onClick="return validateForm()"
in place of onClick=validateForm()
. Thank you so much @epascarello for your quick answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.