Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- function validateForm() {
- let x = document.forms["nameForm"]["name"].value;
- if (x == "") {
- alert("Name must be filled out");
- return false;
- }
- }
- </script>
- </head>
- <body>
- <h2>JavaScript Validation</h2>
- <form name="nameForm" action="" onsubmit="return validateForm()" method="post">
- Name: <input type="text" name="name">
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment