Advertisement
jchaven

Validate field using Javascript

Jan 24th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.59 KB | None | 0 0
  1.  
  2. <script type="text/javascript">
  3. <!-- hide
  4.  
  5.  
  6. function validateFormLocal(theForm) {
  7.  
  8.   // check for a post title
  9.   if (theForm.frmTitle.value == "") {
  10.         alert("Please enter a title for the post.");
  11.         theForm.frmTitle.focus();
  12.         return false;
  13.     }
  14.  
  15.   // if all checks pass submit form
  16.   return true;
  17. }
  18.  
  19. // done hiding -->
  20. </script>
  21.  
  22.  
  23. <form action="process.php" method="post" onsubmit="return validateFormLocal(this)" name="FormPost">
  24.  
  25.    <label for="frmTitle" class="txtlabel">Title:</label>
  26.    <span><input type="text" name="frmTitle" id="frmTitle"></span>
  27.  
  28. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement