topical media & game development

talk show tell print

#javascript-form-validate-demo.htm / htm



  <head>
  
  <!-- Paste this code into the HEAD section of your HTML document.
       You may need to change the path of the file.  -->
  
  <script type="text/javascript" src="javascript-form-validate-script.js"></script>
  </head>
  <body>
  
  <!-- Paste this code into the HEAD section of your HTML document  -->
  
  <script type="text/javascript">
  <!--
  /* This script and many more are available free online at
  The JavaScript Source :: http://javascript.internet.com
  Created by: Amit Wadhwa :: http://amitwadhwa.fcpages.com/javascript.com/formvalidator.html */
  
  function check(formname, submitbutton) {
    var errors = '';
    errors += checkText(formname, 'textfield1', 'Name');
    errors += checkSelect(formname, 'Country', 'Country Of Residence');
    errors += checkText(formname, 'age', 'Age Of Person');
    errors += checkNum(formname, 'age', 'Age Of Person');
    errors += checkRadio(formname, 'Gender', 'Your gender');
    checkThisForm(formname, submitbutton, errors);
  }
  
-> </script> </head> <body> <!-- Paste this code into the BODY section of your HTML document --> <form name="form1"> <p>Enter Name: <input type="text" name="textfield1"> (Mandatory)</p> <p>Enter Country of Residence: <select name="Country"> <option value="" selected>- Select Country -</option> <option value="India">India</option> <option value="China">China</option> <option value="UK">UK</option> <option value="USA">USA</option> </select> (Mandatory)</p> <p>Enter Age: <input type="text" name="age"> (Mandatory, Must be a number)</p> <p> Gender <input type="radio" name="Gender" value="M"> Male <input type="radio" name="Gender" value="F"> Female (Mandatory - select one)</p> <p> <input type="button" name="Submit" value="submit" onClick="check('form1', this.name);"></p> </form> <p><div align="center"> <font face="arial, helvetica" size"-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </div><p> </body>

[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-2780434-1"; urchinTracker(); </script>