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: 06:42 - Mar 17, 2011  

adamfry1

How to confirm radio buttons in javascript?

I have a problem,javascript validation form put this in and check it out yourself then you will see my problem:

<html>
<head>
<title>Entry Form</title>

<script language="javascript" type="text/javascript">

function validateForm()
{
var result = true;
var msg="";
    var examnumberlimit = 4
if (document.ExamEntry.name.value=="") {
msg+="You must enter your name \n";
document.ExamEntry.name.focus();
document.getElementById('name').style.color="red";
result = false;
}

if (document.ExamEntry.subject.value=="") {
msg+="You must enter the subject \n";
document.ExamEntry.subject.focus();
document.getElementById('subject').style.color="red";
result = false;
}

if (document.ExamEntry.subject.value=="") {
msg+="You must enter the exam number \n";
document.ExamEntry.subject.focus();
document.getElementById('examnumber1').style.color="red";
result = false;
}
    
if(document.ExamEntry.examnumber.value.length==examnumberlimit) {

    }
    else
    {
     msg+=" Your exam number must be four digits long ";
     document.ExamEntry.examnumber.focus();
     document.getElementById('examnumber').style.colour="red";
     result = false;
    }
    if ( ( document.ExamEntry.option[0].checked == false )
&& ( document.ExamEntry.option[1].checked == false ) )
{
alert ( "Please choose your entry level" );
valid = false;
}

if(msg==""){
return result;
}
{
alert(msg)
return result;
}
    
    for (var i=0; i < document.ExamEntry.ExamLevel.length; i++)
    {
    if (document.ExamEntry.ExamLevel[i].checked)
    {
    level = document.ExamEntry.ExamLevel[i].value;
    }
    }
    
    ConfirmMSg = confirm(level)
    
    if (ConfirmMSg== true)
    {
    }
    
    else
     {
    result = false;
      return result;
    exit()
     }
  
  }
</script>

</head>

<body>
<h1>Exam Entry Form</h1>

<form name="ExamEntry" method="post" action="success.html">
<table width="50%" border="0">
<tr>
<td id="name">Name</td>
<td><input type="text" name="name" /></td>
</tr>


<tr>
<td id="subject">Subject</td>
<td><input type="text" name="subject" /></td>
</tr>

<tr>
<td id="examnumber1">Exam Number</td>
<td><input name="examnumber" type="text" size="4" /></td>
</tr>


<tr>
    <td>Examination Level</td>
<td><input type="radio" name="option" value="GCSE"> GCSE <br>
<input type="radio" name="option" value="AS" > AS <br>
<input type="radio" name="option" value="A2"> A2 </td>


</tr>


    <tr>
<td><input type="submit" name="Submit" value="Submit" onClick="return validateForm();" /></td> <td><input type="reset" name="Reset" value="Reset" /></td>
</tr>

</table>
</form>

</body>

</html>

Answer Discussion
Tutorials

 

ggggg

Date:: Mar 15, 2012

Time:: 10:57

its wrong

cheek1541

Date:: Mar 25, 2012

Time:: 09:28

dude it doesn't even work as instructed,I have the same task and I've completed it for GCSE you've got yours a bit messed up.

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

10354

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