Can anyone solve the error of this program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Can anyone solve the error of this program

https://code.sololearn.com/WeUulq9r3G3Z/?ref=app

17th Oct 2019, 2:39 PM
Tanmay Gupta
Tanmay Gupta - avatar
3 Answers
+ 4
In html <form onsubmit="validate(event)"> ... </form> In javascript function validate(evt){ evt.preventDefault(); var n1 = document.getElementById("num1"); var n2 = document.getElementById("num2"); if(n1.value !=""&&n2.value !=""){ if(n1.value==n2.value){ return true; } } alert("Value of both the passwords should match"); return false; }
17th Oct 2019, 3:12 PM
Calviղ
Calviղ - avatar
+ 4
Replace js code by this. function validate() { var n1 = document.getElementById("num1"); var n2 = document.getElementById("num2"); if(n1.value != "" &&n2.value != "") { if(n1.value == n2.value) { alert ('Success'); return true; } alert("Value of both the passwords should match"); } return false; }
17th Oct 2019, 3:14 PM
A͢J
A͢J - avatar
+ 2
Use this <input type="button" onclick="return validate()" value="Submit">
17th Oct 2019, 3:10 PM
A͢J
A͢J - avatar