<!-- <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> function helloworld(){ document.write("hello world"); } </script> <form> <input type="submit" onclick = helloworld()> </form> </body> </html> --> <!-- <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script> function validateform(){ var name=document.getElementById("name").value; var roll=document.getElementById("roll").value; if(name==="" || roll===""){ alert("name and roll required"); return false } return true; } </script> </head> <body> <form > <label for ="name">Name</label> <input type="txt" id="name"> <label for ="roll" >roll</label> <input type="number" id ="roll"> <input type="submit"onclick=validateform()); </form> </body> </html> -->