Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Open Points: 125 Time: 11:08 - Apr 11, 2008  

zamro

radio button validation

I need to be able to validat drop <select> menus text feilds and radio button all in one function. So far I have been able to validate the <select> menus and the text feilds but i am still having trouble witht he radio buttons. heres the code I have so far.

<html>
<head>
<title></title>
<script type="text/javascript">

//check to make sure text feilds are not empty


function validateForm() {

if (document.application.fname.value == "") {
alert("This field is empty."); //Informs user of empty field
document.application.fname.focus();
return false;
}


if (document.application.lname.value == "") {
alert("This field is empty."); //Informs user of empty field
document.application.lname.focus();
return false;
}

if (document.application.cmail1.value == "") {
alert("This field is empty."); //Informs user of empty field
document.application.cmail1.focus();
return false;
}

if (document.application.cmail.value == "") {
alert("This field is empty."); //Informs user of empty field
document.application.cmail.focus();
return false;
}

if (document.application.college.value == "0") {
alert("This field is empty."); //Informs user of empty field
document.application.college.focus();
return false;
}

if (document.application.age.value == "0") {
alert("This field is empty."); //Informs user of empty field
document.application.age.focus();
return false;
}

if (form.application.act.value == "") {
alert("This field is empty."); //Informs user of empty field
form.application.act.focus();
return false;
}




}







</script>
<body>


<h1>Computer Programmer application</h1>






<h2> Apllication For What ever I Think Of Using It For</h2>


<form name="application" action="http://www.waukesha.k12.wi.us/iqa/formTe... method="get" onsubmit="return validateForm()">




First name:
<input type="text" name="fname" />
<br />
Last name:
<input type="text" name="lname" />
<br><br>
E-Mail
<input type="text" name="cmail1" />
<br />
confirm E-mail
<input type="text" name="cmail" />
<br><br>




<select name="college">
<option value ="0">Years In College</option>
<option value ="1">0</option>
<option value ="2">1</option>
<option value ="3">2</option>
<option value ="4">3</option>
<option value ="5">4</option>
<option value = 6">5+</option>
</select>
<br>
<br>





<select name="age">
<option value ="0">select your age</option>
<option value ="age1">5-10</option>
<option value ="age2">11-15</option>
<option value ="age3">16-20</option>
<option value ="age4">21-25</option>
</select>
<br><br>





<h2>My Favorite Activity Is</h2>

<input type="radio" name="act" value="1">Biking<br>

<input type="radio" name="act" value="2">Sports<br>

<input type="radio" name="act" value="3">V-Games<br>

<input type="radio" name="act" value="4">Sleeping<br>





<h2>My Favorite Food Is</h2>

<input type="radio" name="food" value="1">pizza<br>

<input type="radio" name="food" value="2">burgers<br>

<input type="radio" name="food" value="3">mac&cheese<br>

<input type="radio" name="food" value="4">subs<br><br>




<input type=submit value=submit>
<input type=reset value=reset>
</form>
</body>
</html>

Categories

Answer Discussion
Tutorials

 

This question has not yet been answered.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Tutorials cannot be submitted until the Answer Discussion is complete.

Submit answers in the Answer Discussion area

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es