Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

9 Javascripts You Better Not Miss!

By Kiran Pai
2005-06-11


Example 8 : Checking the form contents before submitting the form

This is once again an extremely important use of Javascript (this was one of the primary uses of Javascript). It reduces the time and resources on the server side for checking of online forms. Once again I have found many implementations of this script. This is one I find easy to understand.

<SCRIPT LANGUAGE = "JavaScript">
<!--
function isReady(recv_form) {
 if (recv_form.feedback.value != "")
  return true;
 else {
  alert("Please include a feedback message.");
recv_form.feedback.focus();
return false;
}
}
//-->
</SCRIPT>

<BODY>
<FORM NAME = "myform" onSubmit = "return isReady(this)" METHOD=POST ACTION = "http://www.kiranpai.com/servlet1">
<TEXTAREA NAME = "feedback"></TEXTAREA><br>
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</BODY>


Tutorial Pages:
» 9 Javascripts you better not miss!
» Example 1 : A Single click for checking-unchecking multiple check boxes
» Example 2 : Opening a page (existing as well as dynamic) in a new window without bars, buttons, etc.
» Example 3 : Multiple submit buttons on a single form (Submitting same form to any one of many programs)
» Example 4 : Emulating Browsers Back-Forward buttons
» Example 5 : Making the Output of a program (servlet/cgi program) to appear in a new frame
» Example 6 : Displaying a Countdown using Javascript
» Example 7 : Changing images with MouseOver and MouseOut events
» Example 8 : Checking the form contents before submitting the form
» Example 9 : Filling the values of a dropdown SelectMenu depending on the selection in another Menu


 | Bookmark
Related Tutorials:
» JavaScript Debugging Techniques with Firebug
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Essential Javascript -- A Javascript Tutorial
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function