Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="POST" id="form1" action="target.php">
- ...
- <input type="submit" name="submit" value="Submit"/>
- </form>
- function validateForm()
- {
- var x=document.forms["myForm"]["fname"].value;
- if (x==null || x=="")
- {
- alert("First name must be filled out");
- return false;
- }
- }
- <form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post">
- First name: <input type="text" name="fname">
- <input type="submit" value="Submit">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement