0

onsubmit return function

isn't `return` redundant in onsubmit="return validate()"? Full code: <form onsubmit="return validate()" method="post"> Number: <input type="text" name="num1" id="num1" /> <br /> Repeat: <input type="text" name="num2" id="num2" /> <br /> <input type="submit" value="Submit" /> </form> function validate() { var n1 = document.getElementById("num1"); var n2 = document.getElementById("num2"); if(n1.value != "" && n2.value != "") { if(n1.value == n2.value) { return true; } } alert("The values should be equal and not blank"); return false; }

13th May 2020, 8:48 PM
Vitali Avagyan
Vitali Avagyan - avatar
1 Respuesta
13th May 2020, 9:29 PM
BroFar
BroFar - avatar