hi i am trying to check if the user select yes or no ..it dos work but it give me an error saying "object doesn't support this property or method"

{
var o = document.getElementById('addyes');
var t = document.getElementById('addno');
if ( (o.checked == false ) && (t.checked == false ) )
{
alert ("Would you like any additional drivers? : Yes/No" );
document.carinsurance.additional.focus();
return false;
}
return true;
}

can any help me in that plz??

Recommended Answers

All 10 Replies

Perhaps you wanted something like this:

<html>
<head>
<script type="text/javascript">
function check()
{
	var o = document.getElementById('addyes');
	var t = document.getElementById('addno');
	
	if ( (o.checked == false ) && (t.checked == false ) )
	{
		var ask = confirm("Would you like to add drivers?");
		
		//if user clicked ok
		if(ask)
		{
		// do something
		document.getElementById('additional').focus();
		return false;
		}
		
		else
		{
		alert("Ok. Suit yourself.");
		}
	}
	return true;
}
</script>
</head>
<body>

<p>Answer Me:</p>
<form id="carinsurance">
<input type="radio" name="browser" id="addyes" value="addyes">add YES<br />
<input type="radio" name="browser" id="addno" value="addno">add NO<br />
<br />

Additional: <input type="text" id="additional" size="20" />

<input type="button" onClick="check()" value="GO" />
</form>

</body>
</html>

no .... what i mean there is form the user have to enter all the information but when it com to this question which it asked if he need to add other information ..the user must select yes or no ..if he don't select massage will appear to alert him that he cant submit the form without selecting yes or no...

no .... what i mean there is form the user have to enter all the information but when it com to this question which it asked if he need to add other information ..the user must select yes or no ..if he don't select massage will appear to alert him that he cant submit the form without selecting yes or no...

It wasn't clear the first time.

<html>
<head>
<script type="text/javascript">
function check()
{
	var o = document.getElementById('addyes');
	var t = document.getElementById('addno');
	
	if ( (o.checked == false ) && (t.checked == false ) )
	{

		alert('You must select whether you want additional drivers.');
		document.getElementById('additional').focus();
		return false;
	}
	else return true;
}
</script>
</head>
<body>

<p>Answer Me:</p>
<form id="carinsurance">
<p>Do you want additional drivers: (please check a box)</p>
<input type="radio" name="browser" id="addyes" value="addyes">add YES<br />
<br />
<input type="radio" name="browser" id="addno" value="addno">add NO<br />
<br />

Additional: <input type="text" id="additional" size="20" />

<input type="button" onClick="check()" value="Submit" />
</form>

</body>
</html>

That's just the functionality, you can change what happens inside the conditional. =/

ok that's great coz it is working but when i add other text field it do sent work... can u explain more in the given code

like the user cant leave his name and his email empty

Recall that you give a 'name' to a group of checkboxes/buttons in your html code like this. To easily loop through all the checkboxes, use the getElementsByName method. Here is a demo using checkboxes and radio buttons.

<html>
<head>
<script type="text/javascript">
function check()
{

	var group1 = document.getElementsByName('interests'); //assigns 'interests' checkboxes to group1 -- it becomes an array
	var checkedbox = false;
	var group2 = document.getElementsByName('gender'); // assigns 'gender' radio buttons to group2
	var checkedbutton = false;


for (i=0; i<group1.length; i++) //loop through 'interests' array
	{
	if (group1[i].checked == true)
	{// do something but for this example:
	checkedbox = true;
	break;
	}
	else
	{
	checkedbox = false;
	}
	}

	for (i=0; i<group2.length; i++) // loop through 'gender' array
	{
	if (group2[i].checked == true)
	{// do something
	checkedbutton = true;
	break;
	}
	else
	{
	checkedbutton = false;
	}
	}

	if (checkedbox == false) alert('Please check at least one box');
	if (checkedbutton == false) alert('Please check at least one button');
}
</script>
</head>
<body>

<form id="carinsurance">
<p>Check one or more[interests]:</p>
Design: <input type="checkbox" name="interests" value="design" /><br />
Sports: <input type="checkbox" name="interests" value="sports"  /><br />
Sleeping: <input type="checkbox" name="interests" value="sleeping"  /><br />

<p>Check one[gender]:</p>
Male: <input type="radio" name="gender" value="M" /><br />
Female: <input type="radio" name="gender" value="F"  /><br />
Its' complicated: <input type="radio" name="interests" value="IC"  /><br />

<input type="button" value="GO" onClick="check()" />
</form>

</body>
</html>

The red code corresponds to the checkbox-related script.
Green code is for the radio buttons.

Here is how to check if an input field is empty (javascript code):

var email = document.getElementById('email').value;

if (email == undefined || email == '')
{
alert('Please enter an email address');
}

First you get the 'value' of the text field and assign it to a variable for convenience (in this example, we used the email variable).
Then you'll check if the email variable is undefined (meaning no value was assigned to it) or if an empty string was assigned to it.

That's basically it. Change the value highlighted in red to the id of the field you want to check.

The check for email == undefined is superfluous since a value of text form field, if it exists will never be `undefined' or `null' but always a empty string if nothing was entered. You should rather check the return value of getElementById() so that you don't end up trying to access the `value' property of something which doesn't exist. Also the above validation can be easily bypassed by entering just whitespaces. Maybe a trim is in order?

function validate() {
  var e = document.getElementById('emailId');
  if(!e) return false;
  var txt = trim(e.value); // here trim() is a custom function
  if(txt === '') {
    alert('Please enter an email id.');
    return false;
  }
  return true;
}

./sos

commented: he owned me +2
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script language="JavaScript">

  function car(carinsurance)
  		{
if(carinsurance.title.value=="---")
	     {
	      alert("Please select your titel");
	      carinsurance.title.focus();
	  	   return;
		 }
if(carinsurance.name.value=="")
	     {
	      alert("Please enter your Name");
	      carinsurance.name.focus();
	      carinsurance.name.select();
	  	   return;
		 }
		 
if(carinsurance.surname.value=="")
{
alert("Please enter your Surname");
carinsurance.surname.focus();
carinsurance.surname.select();
 return;
}

if(carinsurance.dobd.value=="---")
{
alert("Please select the day of your birth");
carinsurance.dobd.focus();
 return;
}

if(carinsurance.dobm.value=="---")
{
alert("Please select the month of your birth");
carinsurance.dobm.focus();
 return;
}

if(carinsurance.doby.value=="")
{
alert("Please enter the year of your birth");
carinsurance.doby.focus();
carinsurance.doby.select();
 return;
}

if(carinsurance.doby.value < 0 || isNaN(carinsurance.doby.value))
	     {
	      alert("Invalid Entry ! Numeric data required for this field. ");
	      carinsurance.doby.focus();
	      carinsurance.doby.select();
	  	   return;
		 }		    

if(carinsurance.occupation.value=="---")
{
alert("Please slect your Occupation");
carinsurance.occupation.focus();
 return;
}

if(carinsurance.status.value=="---")
{
alert("Please slect your Marital Status");
carinsurance.status.focus();
 return;
}

if(carinsurance.licence.value=="---")
{
alert("Please slect your Marital Status");
carinsurance.licence.focus();
 return;
}

if(carinsurance.period.value=="---")
{
alert("Please select the Period licence held");
carinsurance.period.focus();
 return;
}

if(carinsurance.email.value=="")
{
alert("Please Enter a Valid Email");
carinsurance.email.focus();
carinsurance.email.select();
 return;
}

 if(carinsurance.email.value.indexOf("@") < 0 && carinsurance.email.value.indexOf(".") < 0) {
		alert("The E-Mail Shuld Be In This Format addres@domain.com");
		carinsurance.email.focus();
		carinsurance.email.select();
		return;
	    }
{
var addo = document.getElementById('addyes');
var addt = document.getElementById('addno');
if ( (addo.checked == false ) && (addt.checked == false ) )
{
alert ("Would you like any additional drivers? : Yes/No" );
return;
}
return ;
}

{
var claimo = document.getElementById('claimsyes');
var claimt = document.getElementById('claimsno');
if ( (claimo.checked == false ) && (claimt.checked == false ) )
{
alert ("Have you made any claims in the past 5 years? : Yes/No" );
return;
}
return ;
}

carinsurance.submit();
  } 
</script>

</head>

<body>
<table width="100%" border="0">
  <tr>
    <td width="100%" valign="top"><form name="carinsurance" method="post" action="">
      <table width="85%" border="0" align="center" cellspacing="3">
        <tr>
          <td colspan="2" bgcolor="#0F8EE2"><span class="sectionTitle style27"> <span class="style28"> <br>
            &nbsp;Vehicle details</span> <br>
            </span></td>
          </tr>
        <tr>
          <td width="47%" height="6" valign="top" bgcolor="#EEEEEE"><span class="input style27">
            <!-- label_title -->
            <label for="Salutation"> <span class="style29"><br>
              &nbsp;Title</span></label>
            <!-- widget_title -->
            <br>
            </span></td>
          <td width="40%" bgcolor="#EEEEEE"><span class="input"><span class="widget style27">
            <select name="title" class="style12" tabindex="10">
              <option value="---" selected> </option>
              <option value="Mr">Mr</option>
              <option value="Mrs">Mrs</option>
              <option value="Miss">Miss</option>
              <option value="Ms">Ms</option>
              <option value="Dr">Dr</option>
              </select>
            </span></span></td>
          </tr>
        <tr>
          <td valign="middle" bgcolor="#EEEEEE"><span class="input style27"> <span class="style29">
            <!-- label_forename -->
            <label for="surname"><br>
              &nbsp;First name </label>
            </span>
            <!-- widget_forename -->
            <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="input"><span class="widget style27">
            <input name="name" size="20" tabindex="21" value="" class="style12" type="text">
            </span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10 style27"><br>
            &nbsp;Surname<br></td>
          <td bgcolor="#EEEEEE"><span class="widget style27">
            <input name="surname" size="20" tabindex="21" value="" id="Forename2" class="style12" type="text">
            </span></td>
          </tr>
        <tr>
          <td valign="middle" bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_dob -->
            <label for="dob_day"><br>
              &nbsp;Date of birth </label>
            <!-- widget_dob -->
            <label for="dob_day" class="style10"> Date of birth </label>
            <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget"><span class="sub-widget style27">
            <select name="dobd" tabindex="40" id="dob_day" class="style12">
              <option value="---" selected> </option>
              <option value="1">01</option>
              <option value="2">02</option>
              <option value="3">03</option>
              <option value="4">04</option>
              <option value="5">05</option>
              <option value="6">06</option>
              <option value="7">07</option>
              <option value="8">08</option>
              <option value="9">09</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              <option value="17">17</option>
              <option value="18">18</option>
              <option value="19">19</option>
              <option value="20">20</option>
              <option value="21">21</option>
              <option value="22">22</option>
              <option value="23">23</option>
              <option value="24">24</option>
              <option value="25">25</option>
              <option value="26">26</option>
              <option value="27">27</option>
              <option value="28">28</option>
              <option value="29">29</option>
              <option value="30">30</option>
              <option value="31">31</option>
              </select>
            <select name="dobm" tabindex="50" id="dob_month" class="style12">
              <option value="---" selected></option>
              <option value="1">Jan</option>
              <option value="2">Feb</option>
              <option value="3">Mar</option>
              <option value="4">Apr</option>
              <option value="5">May</option>
              <option value="6">Jun</option>
              <option value="7">Jul</option>
              <option value="8">Aug</option>
              <option value="9">Sept</option>
              <option value="10">Oct</option>
              <option value="11">Nov</option>
              <option value="12">Dec</option>
              </select>
            <input name="doby" maxlength="4" size="4" tabindex="60" value="" id="dob_year" class="style12" type="text">
            </span></span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10 style27"><br>
            &nbsp;Occupation<br></td>
          <td bgcolor="#EEEEEE"><span class="widget style27">
            <select name="occupation" class="style12" id="Occupation" tabindex="80">
              <option value="---" selected></option>
              <option value="Professional Exc.Sport/Tv/Film">Professional Exc.Sport/Tv/Film</option>
              <option value="Company Director">Company Director</option>
              <option value="Skilled">Skilled</option>
              <option value="Manual">Manual</option>
              <option value="Clerical">Clerical</option>
              <option value="Customer Services">Customer Services</option>
              <option value="H M Forces">H M Forces</option>
              <option value="Drivers">Drivers</option>
              <option value="Motor Trade">Motor Trade</option>
              <option value="Housewife/Husband">Housewife/Husband</option>
              <option value="Proprietor">Proprietor</option>
              <option value="Student">Student</option>
              <option value="Retired">Retired</option>
              <option value="Unemployed">Unemployed</option>
              </select>
            </span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_license_type -->
            <label for="licenceType">&nbsp; </label>
            <!-- widget_licensetype -->
            <br>
            &nbsp;                Marital Status <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget style27">
            <select name="status" tabindex="90" id="licenceTypeId" class="style12">
              <option value="---" selected> </option>
              <option value="Single">Single</option>
              <option value="Married">Married</option>
              <option value="Divorced">Divorced</option>
              <option value="Widowed">Widowed</option>
              </select>
            </span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10 style27"><br>
            &nbsp;                Type of licence</td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget style27">
            <select name="licence" tabindex="90" id="licenceType" class="style12">
              <option value="---" selected> </option>
              <option value="Full">Full</option>
              <option value="Provisional">Provisional</option>
              <option value="Provisional">Provisional</option>
              <option value="International">International</option>
              </select>
            </span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_period_licence_held -->
            <label for="periodLicenceHeld"><br>
              &nbsp;Period licence held </label>
            <!-- widget_period_licence_held -->
            <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget style27">
            <select name="period" tabindex="110" id="periodLicenceHeld" class="style12">
              <option value="---" selected> </option>
              <option value="0 years">0 years</option>
              <option value="1 year">1 year</option>
              <option value="2 years">2 years</option>
              <option value="3 years">3 years</option>
              <option value="4 years">4 years</option>
              <option value="5 years">5 years</option>
              <option value="6 years">6 years</option>
              <option value="7 years">7 years</option>
              <option value="8 years">8 years</option>
              <option value="9 years">9 years</option>
              <option value="10 + years">10 + years</option>
              </select>
            </span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_emailaddress -->
            <label for="email"><br>
              &nbsp;E-mail address </label>
            <!-- widget_emailaddress -->
            <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget style27">
            <input name="email" maxlength="60" size="20" tabindex="120" value="" id="email" class="style12" type="text">
            </span></span></span></td>
          </tr>
        <tr>
          <td valign="bottom" bgcolor="#EEEEEE" class="style10"><span class="input"> <span class="stanzaSpacer style27">
            <!-- label_mobile_number -->
            <label for="mobilenumber"></label>
            <br>
            &nbsp;Best contact number (mobile, home, work)<br>
            </span></span></td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget style27">
            <input name="mobilenumber" maxlength="11" size="20" tabindex="145" value="" id="mobilenumber" class="style12" type="text">
            </span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="stanzaSpacer style27">
            <label for="Premise"><br>
              &nbsp;House number or name </label>
            <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="widget style27">
            <input name="mobilenumber2" maxlength="11" size="20" tabindex="145" value="" id="mobilenumber2" class="style12" type="text">
            </span></td>
          </tr>
        <tr>
          <td valign="middle" bgcolor="#EEEEEE" class="style10 style27"><br>
            &nbsp;Postcode<br></td>
          <td bgcolor="#EEEEEE"><span class="input style27">
            <input name="postcode" maxlength="8" size="20" tabindex="200" value="" id="postCode" class="style12" type="text">
            </span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="style12 style27">
            <!-- label_cover_start_date -->
            <label for="coverstartdate_day"><br>
              &nbsp;When would you like your policy to start? </label>
            <label for="coverstartdate_day" class="hidden_label"> </label>
            <label for="coverstartdate_month" class="hidden_label"> </label>
            <label for="coverstartdate_year" class="hidden_label"> </label>
            <br>
            </span></td>
          <td bgcolor="#EEEEEE"><span class="style10"><span class="input"><span class="widget"><span class="sub-widget style27">
            <select name="startDateDay" tabindex="210" id="coverstartdate_day" class="style12">
              <option value=""></option>
              <option value="1">01</option>
              <option value="2">02</option>
              <option value="3">03</option>
              <option value="4">04</option>
              <option value="5">05</option>
              <option value="6">06</option>
              <option value="7">07</option>
              <option value="8">08</option>
              <option value="9">09</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              <option value="17">17</option>
              <option value="18">18</option>
              <option value="19">19</option>
              <option value="20">20</option>
              <option value="21">21</option>
              <option value="22">22</option>
              <option value="23">23</option>
              <option value="24">24</option>
              <option value="25">25</option>
              <option value="26">26</option>
              <option value="27">27</option>
              <option value="28">28</option>
              <option value="29">29</option>
              <option value="30">30</option>
              <option value="31">31</option>
              </select>
            <select name="startDateMonth" tabindex="220" id="coverstartdate_month" class="style12">
              <option value=""></option>
              <option value="1">Jan</option>
              <option value="2">Feb</option>
              <option value="3">Mar</option>
              <option value="4">Apr</option>
              <option value="5">May</option>
              <option value="6">Jun</option>
              <option value="7">Jul</option>
              <option value="8">Aug</option>
              <option value="9">Sept</option>
              <option value="10">Oct</option>
              <option value="11">Nov</option>
              <option value="12">Dec</option>
              </select>
            <select name="startDateYear" tabindex="230" id="coverstartdate_year" class="style12">
              <option value=""></option>
              <option value="2008">2008</option>
              <option value="2009">2009</option>
              </select>
            </span></span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10 style27"><span class="stanzaSpacer"> <span class="stanzaLabel">
            <!-- label_additional_drivers -->
            <label for="additionalDrivers_no"><br>
              &nbsp;Would you like any additional drivers? </label>
            </span></span> <span class="widget">
              <!-- widget_additional_drivers -->
              <br>
            </span></td>
          <td bgcolor="#EEEEEE" class="style12 style27"><span class="style30"><span class="sub-widget"><span class="inputLabel">
            <label for="additionalDrivers_no"></label>
            </span>
            <label> </label>
            </span></span>
            <label> <span class="style31">
              <input type="radio" name="additional" id="addyes" value="yes">
              Yes </span></label>
            <span class="style31">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="radio" name="additional" id="addno" value="no">
              No
              <label></label>
            </span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input"><span class="stanzaSpacer"> <span class="style12 style27">
            <!-- label_motorclaims -->
            <label for="motorClaims_no"><br>
              &nbsp;Have you made any claims in the past 5 years? </label>
            <br>
            </span></span></span></td>
          <td bgcolor="#EEEEEE" class="style12 style27"><span class="sub-widget">
            <label> </label>
            </span>
            <label>
              <input type="radio" name="claims" id="claimsyes" value="cyes">
              Yes </label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="claims" id="claimsno" value="cno">
            No
            <label></label></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27"> <span class="style29">
            <!-- label_motorconvictions -->
            <label for="motorConvictions_no"><br>
              &nbsp;Have you had any convictions in the past 5 years? </label>
            </span>
            <!-- widget_claim_type -->
            <label for="motorConvictions_yes"></label>
            <br>
            </span></td>
          <td bgcolor="#EEEEEE" class="style12 style27"><label>
            <input type="radio" name="radio" id="radio5" value="radio">
            Yes </label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="radio2" id="radio6" value="radio2">
            No
            <label></label></td>
          </tr>
        <tr>
          <td colspan="2" bgcolor="#0F8EE2" class="style10"><span class="sectionTitle style27"> <span class="style22"><br>
            &nbsp;Please tell us about your vehicle </span> <br>
            </span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_car_registration -->
            <label for="carRegistration"><br>
              &nbsp;Registration number (if known) </label>
            <!-- widget_car_registration -->
            <br>
            </span></td>
          <td bgcolor="#EEEEEE" class="style12"><span class="style10"><span class="input"><span class="widget style27">
            <input name="vehicleRegistration" maxlength="10" size="20" tabindex="370" value="" id="carRegistration" class="style12" type="text">
            </span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_car_registration -->
            <label for="label"><br>
              &nbsp;Car Make (If Reg not known) </label>
            <!-- widget_car_registration -->
            <em><br>
              &nbsp;              (e.g – 2004, 3 door,  corsa 1.2 sxi, etc)</em><br>
            </span></td>
          <td valign="middle" bgcolor="#EEEEEE" class="style12"><span class="widget style27">
            <input name="carRegistration" maxlength="10" size="20" tabindex="370" value="" id="carRegistration2" class="style12" type="text">
            </span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_car_registration -->
            <label for="label"><br>
              &nbsp;Car Model</label>
            <!-- widget_car_registration -->
            <br>
            </span></td>
          <td bgcolor="#EEEEEE" class="style12"><span class="widget style27">
            <input name="carRegistration2" maxlength="10" size="20" tabindex="370" value="" id="carRegistration3" class="style12" type="text">
            </span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_annual_mileage -->
            <label for="annualMileage"><br>
              &nbsp;Estimated annual mileage </label>
            <!-- widget_annual_mileage -->
            <br>
            </span></td>
          <td valign="middle" bgcolor="#EEEEEE" class="style12"><span class="style10"><span class="input"><span class="widget style27">
            <select name="annualMileageId" tabindex="390" id="annualMileage" class="style12">
              <option value=""></option>
              <option value="1000">Up to 1000</option>
              <option value="2000">Up to 2000</option>
              <option value="3000">Up to 3000</option>
              <option value="4000">Up to 4000</option>
              <option value="5000">Up to 5000</option>
              <option value="6000">Up to 6000</option>
              <option value="7000">Up to 7000</option>
              <option value="8000">Up to 8000</option>
              <option value="9000">Up to 9000</option>
              <option value="10000">Up to 10000</option>
              <option value="11000">Up to 11000</option>
              <option value="12000">Up to 12000</option>
              <option value="13000">Up to 13000</option>
              <option value="14000">Up to 14000</option>
              <option value="15000">Up to 15000</option>
              <option value="16000">Up to 16000</option>
              <option value="17000">Up to 17000</option>
              <option value="18000">Up to 18000</option>
              <option value="19000">Up to 19000</option>
              <option value="20000">Up to 20000</option>
              <option value="21000">Up to 21000</option>
              <option value="22000">Up to 22000</option>
              <option value="23000">Up to 23000</option>
              <option value="24000">Up to 24000</option>
              <option value="25000">Up to 25000</option>
              <option value="30000">Up to 30000</option>
              <option value="35000">Up to 35000</option>
              <option value="40000">Up to 40000</option>
              <option value="45000">Up to 45000</option>
              <option value="50000">Up to 50000</option>
              </select>
            </span></span></span></td>
          </tr>
        <tr>
          <td bgcolor="#EEEEEE" class="style10"><span class="input style27">
            <!-- label_vehiclevalue -->
            <label for="vehicleValue"><br>
              &nbsp;Estimated vehicle value </label>
            <!-- widget_vehiclevalue -->
            <br>
            </span></td>
          <td valign="middle" bgcolor="#EEEEEE" class="style12"><span class="widget style27">
            <input name="vehicleValue" maxlength="10" size="20" tabindex="410" value="£" id="vehicleValue" class="style12" type="text">
            </span></td>
          </tr>
        <tr>
          <td valign="middle" bgcolor="#EEEEEE" class="style10"><span class="stanzaSpacer"><span class="stanzaLabel style27">
            <label for="noClaimsDiscount"><br>
              &nbsp;</label>
            No Claims Bonus  earned <br>
            </span></span></td>
          <td bgcolor="#EEEEEE" class="style12"><span class="widget style27">
            <select name="noClaimsDiscountId" tabindex="430" id="noClaimsDiscount" class="style12">
              <option value="0">0</option>
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option>6</option>
              <option>7</option>
              <option>8</option>
              <option>9</option>
              </select>
            </span></td>
          </tr>
        <tr>
          <td height="2" valign="middle" bgcolor="#EEEEEE" class="style10 style27">&nbsp;</td>
          <td height="2" bgcolor="#EEEEEE" class="style10"><span class="style27">
            <label>
              <INPUT name=Submit  type=Button  Onclick = car(carinsurance) value="   Get Quote    ">
              </label>
            </span></td>
          </tr>
        </table>
    </form></td>
  </tr>
  <tr>
    <td valign="top">
    </marquee></td>
  </tr>
</table>
</body>
</html>

the first radio button validation is working but the second is not working plz have a look in the code and let me know what is the wrong...

what i wana do is the user must select yes or no otherwise he cant submit the form..
thanks in advance

Checking out that huge chunk of code for Javascript errors is quite a herculean task.

To ease your development, I would recommend that you carry out your development testing in Firefox and make use of the excellent addon "Firebug" which provides features like Javascript error notifications, debugging facility and much more. If there are any Javascript errors, the error console will point out to you the exact line on which the error has occurred.

the problem is solved thanks any way....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.