SlideShare a Scribd company logo
Lecture 17
You will learn in this Lecture

FormValidation
     - Text Box validation
     - Check Box validation
     - Password validation
     - select list box validation

Before starting with this lecture, There are few questions that deserve to be
answered, What is validation and Why is it requried? Let me answer the first
question and then we will move on to the second question.

So, the first question is, What is validation?
Validation test for required strings contain a specific value, a range of accepted
value or a pattern of acceptable format. For example, If you make a form, and
ask the user to enter name, email address, and comment. If he leaves every field
blank, and click Enter. You will not get any information.
This means we are validating (checking) the values entered by the user, if he has
entered some value or not, if not, then ask him to enter the value and if he has
entered wrong value,then ask him to enter the correct value.

I hope you must have got the answer, why validation is required.

Next question is How validation is done, just read the following lines.

So, as soon as the user clicks Enter, There are two possibilites

1. Send the data that use has entered to the server, and check the values, if
there are any, if there are no values entered by him or if wrong values are
entered by him, ask him to enter the value, and move back to the same form.

2. Or, before sending the data to the server, check whether user has entered any
value or not. If he has entered the value, then the value is corrent or not.

Second method is what we will follow, and is called as client side scripting,
whereas the first method is called as Serve side scripting. JavaScript is popular
for client side scripting and ASP, JSP, PHP are popular for server side scripting.
It is high time to understand the difference between Client Side Scripting and
Server Side Scripting.

When we use a scripting language, that works on the server side, it is called as
Server Side Scripting language,
If we use a scripting language, that works on client side (i.e. browser), it is called
as Client Side Scripting language.
So, Now let us start with validating user input.

When we make a form, we ask the user to enter username, password, and may
ask him to fill up some check boxes, radio butons, and also ask him to write
some comments. It is compulsay for the user to enter username, and password,
but it is not compulsay for him to give his comments. So the things that are
compulsary, cannot be left blank. This is one of the validation, forcing the user
not to leave a field blank.

Let me list down some of the common validations needed
- Password Validation
- Text Field not blank (Name)

Below is the code for Text Box validation
<html>
<head>
      <script language="JavaScript">

       function validate()
       {
       firstName=document.myForm.fname.value;
       lastName=document.myForm.fname.value;
       if(firstName=="")
                window.alert("Name Field cannot be left blank");
       if(lastName=="")
                window.alert("Name Field cannot be left blank");
       switch (firstName.charAt(0))
       {
                case "0":
                case "1":
                case "2":
                case "3":
                case "4":
                case "5":
                case "6":
                case "7":
                case "8":
                case "9": window.alert("First chaaracter cannot be a number");
       }
       }

      </script>
</head>
      <body>
      <form name="myForm">
<input type="text" name="fname"> <br>
            <input type="text" name="lname"> <br>
            <input type="submit" onClick="validate()"> <br>
      </form>
      </body>
</html>

And, Now we have the code for Password Validation
<html>
<head>
      <script language="JavaScript">

      function validate()
      {
      passwd=document.myForm.pass;
      cpasswd=document.myForm.cpass;
      if (passwd=="")
              window.alert("Password field cannot be blank");
      if (cpasswd=="")
              window.alert("Confirm Password field cannot be blank");

      if (passwd!=cpasswd)
              window.alert("Passwords dont match");
      }

      </script>
</head>
      <body>
      <form name="myForm">
             Password<input type="password" name="pass"> <br>
             Confirm password<input type="password" name="cpass"> <br>
             <input type="submit" onClick="validate()"> <br>
      </form>
      </body>
</html>

Validate Selection List

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function validateForm(objForm)
{
       var returnStatus = 1;
if (objForm.Make.selectedIndex == 0) {
      alert("Please select a car make");
      returnStatus = 0;
      }
      else
      alert("You selected" +
objForm.Make.options[objForm.Make.selectedIndex].text + objForm.Make.value);

      if (returnStatus) {
      objForm.submit();
      }
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="test.asp" NAME="testform">
<SELECT NAME="Make">
       <OPTION VALUE="0" SELECTED>Select One</OPTION>
       <OPTION VALUE="1">Ford</OPTION>
       <OPTION VALUE="2">Chevy</OPTION>
       <OPTION VALUE="3">Pontiac</OPTION>
       <OPTION VALUE="4">Dodge</OPTION>
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Send form"
onClick="validateForm(document.testform)">
</FORM>
</BODY>
</HTML>

Dynamically Populating a Selectin List

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function populate(objForm)
{


      if (objForm.Make.selectedIndex == 0)
      {
      alert("Please select a car make");
      }
      else
      {
alert("You selected" +
objForm.Make.options[objForm.Make.selectedIndex].text + objForm.Make.value);
      if (objForm.Make.selectedIndex == 1)
      {
              objForm.Type.length=2;
              objForm.Type.options[0].text="d1";
              objForm.Type.options[0].value="1";

            objForm.Type.options[1].text="d2";
            objForm.Type.options[1].value="2";
      }

      if (objForm.Make.selectedIndex == 2)
      {
              objForm.Type.length=2;
              objForm.Type.options[0].text="h1";
              objForm.Type.options[0].value="1";

            objForm.Type.options[1].text="h2";
            objForm.Type.options[1].value="2";
      }

      if (objForm.Make.selectedIndex == 3)
      {
              objForm.Type.length=3;
              objForm.Type.options[0].text="m1";
              objForm.Type.options[0].value="1";

            objForm.Type.options[1].text="m2";
            objForm.Type.options[1].value="2";

            objForm.Type.options[2].text="m3";
            objForm.Type.options[2].value="3";
      }

      if (objForm.Make.selectedIndex == 4)
      {
              objForm.Type.length=4;
              objForm.Type.options[0].text="v1";
              objForm.Type.options[0].value="1";

            objForm.Type.options[1].text="v2";
            objForm.Type.options[1].value="2";

            objForm.Type.options[2].text="v3";
            objForm.Type.options[2].value="3";
objForm.Type.options[3].text="v4";
            objForm.Type.options[3].value="4";
      }



      }



}
// -->
</SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="test.asp" NAME="testform">
<SELECT NAME="Make" onChange="populate(document.testform)">
       <OPTION VALUE="0" SELECTED>Select One</OPTION>
       <OPTION VALUE="1">Daewoo</OPTION>
       <OPTION VALUE="2">Hyundae</OPTION>
       <OPTION VALUE="3">Mercedes</OPTION>
       <OPTION VALUE="4">Volswagen</OPTION>
</SELECT>

<SELECT NAME="Type">
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Send form"
onClick="validateForm(document.testform)">
</FORM>
</BODY>
</HTML>

Validating a Check Box

More Related Content

PPT
Form validation client side
Mudasir Syed
 
PPT
Javascript sivasoft
ch samaram
 
PPTX
Form Validation in JavaScript
Ravi Bhadauria
 
PPTX
Javascript
D V BHASKAR REDDY
 
PDF
Javascript
Rajavel Dhandabani
 
PPT
Java script Learn Easy
prince Loffar
 
PDF
Javascript essentials
Bedis ElAchèche
 
RTF
Java script frame window
H K
 
Form validation client side
Mudasir Syed
 
Javascript sivasoft
ch samaram
 
Form Validation in JavaScript
Ravi Bhadauria
 
Javascript
D V BHASKAR REDDY
 
Javascript
Rajavel Dhandabani
 
Java script Learn Easy
prince Loffar
 
Javascript essentials
Bedis ElAchèche
 
Java script frame window
H K
 

What's hot (20)

PPT
Form validation server side
Mudasir Syed
 
PPT
28,29. procedures subprocedure,type checking functions in VBScript
VARSHAKUMARI49
 
PPTX
Java scriptfunction
Jesus Obenita Jr.
 
PPT
30,31,32,33. decision and loop statements in vbscript
VARSHAKUMARI49
 
PPT
Java script -23jan2015
Sasidhar Kothuru
 
PPTX
Java Script
Kalidass Balasubramaniam
 
PPT
Html JavaScript and CSS
Radhe Krishna Rajan
 
PPTX
Java script
Shyam Khant
 
PPTX
Java script basics
Shrivardhan Limbkar
 
PPTX
Produce Cleaner Code with Aspect-Oriented Programming
PostSharp Technologies
 
PDF
Intro to JavaScript
Jussi Pohjolainen
 
PPT
Java script
vishal choudhary
 
PPT
PHP - Introduction to PHP Forms
Vibrant Technologies & Computers
 
PPT
05 html-forms
Palakshya
 
ODP
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios
 
PPTX
Java script basic
Ravi Bhadauria
 
PDF
Writing clean code
Angel Garcia Olloqui
 
PDF
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
PDF
Javascript
Aditya Gaur
 
PDF
Javascript
Rajavel Dhandabani
 
Form validation server side
Mudasir Syed
 
28,29. procedures subprocedure,type checking functions in VBScript
VARSHAKUMARI49
 
Java scriptfunction
Jesus Obenita Jr.
 
30,31,32,33. decision and loop statements in vbscript
VARSHAKUMARI49
 
Java script -23jan2015
Sasidhar Kothuru
 
Html JavaScript and CSS
Radhe Krishna Rajan
 
Java script
Shyam Khant
 
Java script basics
Shrivardhan Limbkar
 
Produce Cleaner Code with Aspect-Oriented Programming
PostSharp Technologies
 
Intro to JavaScript
Jussi Pohjolainen
 
Java script
vishal choudhary
 
PHP - Introduction to PHP Forms
Vibrant Technologies & Computers
 
05 html-forms
Palakshya
 
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios
 
Java script basic
Ravi Bhadauria
 
Writing clean code
Angel Garcia Olloqui
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
Javascript
Aditya Gaur
 
Javascript
Rajavel Dhandabani
 
Ad

Viewers also liked (17)

DOC
Html basics 6 image
H K
 
DOC
Java script frame history
H K
 
PDF
Java script objects 2
H K
 
PPT
Week5
H K
 
DOC
Lecture4 isoosi
H K
 
DOC
Lecture2 networkclassification
H K
 
PDF
Assignment4
H K
 
PDF
Assignment sw
H K
 
PDF
Solution2
H K
 
PDF
Set
H K
 
DOC
Lecture1 introductiontonetwork
H K
 
DOC
Html basics 3 font align
H K
 
PDF
Induction
H K
 
DOC
Html basics 10 form
H K
 
DOC
Html basics 1
H K
 
DOC
Html basics 7 table
H K
 
PPT
Week7
H K
 
Html basics 6 image
H K
 
Java script frame history
H K
 
Java script objects 2
H K
 
Week5
H K
 
Lecture4 isoosi
H K
 
Lecture2 networkclassification
H K
 
Assignment4
H K
 
Assignment sw
H K
 
Solution2
H K
 
Set
H K
 
Lecture1 introductiontonetwork
H K
 
Html basics 3 font align
H K
 
Induction
H K
 
Html basics 10 form
H K
 
Html basics 1
H K
 
Html basics 7 table
H K
 
Week7
H K
 
Ad

Similar to Html basics 11 form validation (20)

PPTX
Javascript validating form
Jesus Obenita Jr.
 
PPTX
Form using html and java script validation
Maitree Patel
 
PPTX
Web topic 22 validation on web forms
CK Yang
 
PDF
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
DOCX
Option #1- Form Validation in JavaScript 1- In your text editor- open.docx
farrahkur54
 
PPTX
Java script form validation
AbhishekMondal42
 
PPTX
Javascript ch7
Brady Cheng
 
PDF
phptut2
tutorialsruby
 
PDF
phptut2
tutorialsruby
 
PDF
phptut2
tutorialsruby
 
PDF
phptut2
tutorialsruby
 
PPTX
Form Validation
Graeme Smith
 
PPT
ملخص تقنية تصميم صفحات الويب - الوحدة الرابعة
جامعة القدس المفتوحة
 
KEY
Building & Breaking Web Forms with Quaid-JS
cliener
 
PPTX
Project1 VB
sunmitraeducation
 
PPT
Web Security Mistakes: Trusting The Client
grutz
 
PDF
Forms
Aaron Maturen
 
PDF
Form Validation NG
joaopmaia
 
DOCX
YASH HTML CODES
YashKoli22
 
Javascript validating form
Jesus Obenita Jr.
 
Form using html and java script validation
Maitree Patel
 
Web topic 22 validation on web forms
CK Yang
 
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Option #1- Form Validation in JavaScript 1- In your text editor- open.docx
farrahkur54
 
Java script form validation
AbhishekMondal42
 
Javascript ch7
Brady Cheng
 
phptut2
tutorialsruby
 
phptut2
tutorialsruby
 
phptut2
tutorialsruby
 
phptut2
tutorialsruby
 
Form Validation
Graeme Smith
 
ملخص تقنية تصميم صفحات الويب - الوحدة الرابعة
جامعة القدس المفتوحة
 
Building & Breaking Web Forms with Quaid-JS
cliener
 
Project1 VB
sunmitraeducation
 
Web Security Mistakes: Trusting The Client
grutz
 
Form Validation NG
joaopmaia
 
YASH HTML CODES
YashKoli22
 

More from H K (20)

PDF
Assignment4
H K
 
DOCX
Assignment3
H K
 
PDF
Solution3
H K
 
DOCX
Mid-
H K
 
PDF
Assignment4
H K
 
PDF
Dm assignment3
H K
 
PPT
Proof
H K
 
PDF
Resolution
H K
 
DOCX
Assignment description
H K
 
PDF
Dm assignment2
H K
 
PDF
Dm assignment1
H K
 
PPTX
Logic
H K
 
DOCX
Introduction
H K
 
PDF
Assignment 2 sol
H K
 
PDF
Assignment sw solution
H K
 
PDF
Violinphoenix
H K
 
PDF
Ie project
H K
 
PDF
Assignment cn subnetting
H K
 
PDF
Assignment uplaodfile
H K
 
PDF
Assignment sw
H K
 
Assignment4
H K
 
Assignment3
H K
 
Solution3
H K
 
Mid-
H K
 
Assignment4
H K
 
Dm assignment3
H K
 
Proof
H K
 
Resolution
H K
 
Assignment description
H K
 
Dm assignment2
H K
 
Dm assignment1
H K
 
Logic
H K
 
Introduction
H K
 
Assignment 2 sol
H K
 
Assignment sw solution
H K
 
Violinphoenix
H K
 
Ie project
H K
 
Assignment cn subnetting
H K
 
Assignment uplaodfile
H K
 
Assignment sw
H K
 

Recently uploaded (20)

PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Trends in pediatric nursing .pptx
AneetaSharma15
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
PDF
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Trends in pediatric nursing .pptx
AneetaSharma15
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 

Html basics 11 form validation

  • 1. Lecture 17 You will learn in this Lecture FormValidation - Text Box validation - Check Box validation - Password validation - select list box validation Before starting with this lecture, There are few questions that deserve to be answered, What is validation and Why is it requried? Let me answer the first question and then we will move on to the second question. So, the first question is, What is validation? Validation test for required strings contain a specific value, a range of accepted value or a pattern of acceptable format. For example, If you make a form, and ask the user to enter name, email address, and comment. If he leaves every field blank, and click Enter. You will not get any information. This means we are validating (checking) the values entered by the user, if he has entered some value or not, if not, then ask him to enter the value and if he has entered wrong value,then ask him to enter the correct value. I hope you must have got the answer, why validation is required. Next question is How validation is done, just read the following lines. So, as soon as the user clicks Enter, There are two possibilites 1. Send the data that use has entered to the server, and check the values, if there are any, if there are no values entered by him or if wrong values are entered by him, ask him to enter the value, and move back to the same form. 2. Or, before sending the data to the server, check whether user has entered any value or not. If he has entered the value, then the value is corrent or not. Second method is what we will follow, and is called as client side scripting, whereas the first method is called as Serve side scripting. JavaScript is popular for client side scripting and ASP, JSP, PHP are popular for server side scripting. It is high time to understand the difference between Client Side Scripting and Server Side Scripting. When we use a scripting language, that works on the server side, it is called as Server Side Scripting language, If we use a scripting language, that works on client side (i.e. browser), it is called as Client Side Scripting language.
  • 2. So, Now let us start with validating user input. When we make a form, we ask the user to enter username, password, and may ask him to fill up some check boxes, radio butons, and also ask him to write some comments. It is compulsay for the user to enter username, and password, but it is not compulsay for him to give his comments. So the things that are compulsary, cannot be left blank. This is one of the validation, forcing the user not to leave a field blank. Let me list down some of the common validations needed - Password Validation - Text Field not blank (Name) Below is the code for Text Box validation <html> <head> <script language="JavaScript"> function validate() { firstName=document.myForm.fname.value; lastName=document.myForm.fname.value; if(firstName=="") window.alert("Name Field cannot be left blank"); if(lastName=="") window.alert("Name Field cannot be left blank"); switch (firstName.charAt(0)) { case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": window.alert("First chaaracter cannot be a number"); } } </script> </head> <body> <form name="myForm">
  • 3. <input type="text" name="fname"> <br> <input type="text" name="lname"> <br> <input type="submit" onClick="validate()"> <br> </form> </body> </html> And, Now we have the code for Password Validation <html> <head> <script language="JavaScript"> function validate() { passwd=document.myForm.pass; cpasswd=document.myForm.cpass; if (passwd=="") window.alert("Password field cannot be blank"); if (cpasswd=="") window.alert("Confirm Password field cannot be blank"); if (passwd!=cpasswd) window.alert("Passwords dont match"); } </script> </head> <body> <form name="myForm"> Password<input type="password" name="pass"> <br> Confirm password<input type="password" name="cpass"> <br> <input type="submit" onClick="validate()"> <br> </form> </body> </html> Validate Selection List <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- function validateForm(objForm) { var returnStatus = 1;
  • 4. if (objForm.Make.selectedIndex == 0) { alert("Please select a car make"); returnStatus = 0; } else alert("You selected" + objForm.Make.options[objForm.Make.selectedIndex].text + objForm.Make.value); if (returnStatus) { objForm.submit(); } } // --> </SCRIPT> </HEAD> <BODY> <FORM ACTION="test.asp" NAME="testform"> <SELECT NAME="Make"> <OPTION VALUE="0" SELECTED>Select One</OPTION> <OPTION VALUE="1">Ford</OPTION> <OPTION VALUE="2">Chevy</OPTION> <OPTION VALUE="3">Pontiac</OPTION> <OPTION VALUE="4">Dodge</OPTION> </SELECT> <INPUT TYPE="BUTTON" VALUE="Send form" onClick="validateForm(document.testform)"> </FORM> </BODY> </HTML> Dynamically Populating a Selectin List <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- function populate(objForm) { if (objForm.Make.selectedIndex == 0) { alert("Please select a car make"); } else {
  • 5. alert("You selected" + objForm.Make.options[objForm.Make.selectedIndex].text + objForm.Make.value); if (objForm.Make.selectedIndex == 1) { objForm.Type.length=2; objForm.Type.options[0].text="d1"; objForm.Type.options[0].value="1"; objForm.Type.options[1].text="d2"; objForm.Type.options[1].value="2"; } if (objForm.Make.selectedIndex == 2) { objForm.Type.length=2; objForm.Type.options[0].text="h1"; objForm.Type.options[0].value="1"; objForm.Type.options[1].text="h2"; objForm.Type.options[1].value="2"; } if (objForm.Make.selectedIndex == 3) { objForm.Type.length=3; objForm.Type.options[0].text="m1"; objForm.Type.options[0].value="1"; objForm.Type.options[1].text="m2"; objForm.Type.options[1].value="2"; objForm.Type.options[2].text="m3"; objForm.Type.options[2].value="3"; } if (objForm.Make.selectedIndex == 4) { objForm.Type.length=4; objForm.Type.options[0].text="v1"; objForm.Type.options[0].value="1"; objForm.Type.options[1].text="v2"; objForm.Type.options[1].value="2"; objForm.Type.options[2].text="v3"; objForm.Type.options[2].value="3";
  • 6. objForm.Type.options[3].text="v4"; objForm.Type.options[3].value="4"; } } } // --> </SCRIPT> </HEAD> <BODY> <FORM ACTION="test.asp" NAME="testform"> <SELECT NAME="Make" onChange="populate(document.testform)"> <OPTION VALUE="0" SELECTED>Select One</OPTION> <OPTION VALUE="1">Daewoo</OPTION> <OPTION VALUE="2">Hyundae</OPTION> <OPTION VALUE="3">Mercedes</OPTION> <OPTION VALUE="4">Volswagen</OPTION> </SELECT> <SELECT NAME="Type"> </SELECT> <INPUT TYPE="BUTTON" VALUE="Send form" onClick="validateForm(document.testform)"> </FORM> </BODY> </HTML> Validating a Check Box