Javascript form validation coding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Javascript form validation coding

8th Nov 2016, 7:48 PM
Ajay Bhadwal
Ajay Bhadwal - avatar
2 Answers
+ 3
be more specific and i'll try to help you
8th Nov 2016, 10:49 PM
Maurizio Urso
Maurizio Urso - avatar
+ 2
I found your code, and i correct it. Next time post your code. I suggest you to study harder HTML and JavaScript because your code is full of error. <!DOCTYPE html> <html><head> <title>Javascript form</title> <script type="text/javascript"> function sub () { if(document.getElementById("t1").value==""){ alert("enter your name") } else if (document.getElementById("t2").value==""){ alert("please enter a password"); } else if(document.getElementById("t2").value!=document.getElementById("t3").value){ alert("please enter correct password"); } else if (document.getElementById("t4").value==""){ alert("please enter your address"); } else{ alert("form has been submitted"); } } </script> </head> <body align="center" bgcolor="red"> <h1>.......javascript form.......</h1> <form> <p> <label>user name*</label><input type="text" id="t1"><br /><br /> <label>password*</label><input type="text" id="t2"/><br /><br /> <label>confirm password*</label><input type="text" id="t3"/> <br /><br /> <label>Address*</label><textarea rows="2" cols="25" id="t4"></textarea> <br /><br /> <input type="button" value="submit" onclick="sub()"/> <input type ="reset" value="clear all"/> </p> </form> </body> </html>
9th Nov 2016, 12:00 AM
Maurizio Urso
Maurizio Urso - avatar