Can anyone tell why alert box is not showing up?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Javascript Example</title> <link rel="stylesheet" href="style.css"> </head> <body> <form method="post" action="something.php" name="my Form" onsubmit="return validateForm()"> <div> <label>First Name</label> <input type="text" name="fname" id="firstname"> </div> <div> <label for="">Last Name</label> <input type="text" name="lastname" id="lastname"> </div> <input type="submit" value="submit"/> </form> </div> <script> function validateForm(){ var x = document.forms["myForm"]["fname"].value; if(x == ""){ alert("first name is required"); return false; } } </script> </body> </html>