eXceem

Go Back   eXceem > Off Topic > Technical Help

Claim your amazing £1,000 slots booster bonus now!


Javascript help needed!

This is a discussion on Javascript help needed! within the Technical Help forums, part of the Off Topic category; Hi guys, I'm doing GCSE Computing and I am making a website. For our homework we have to make to ...

Reply
 
Thread Tools
Old 31-10-11, 06:17 PM   #1
iPod Nano 1GB
 
andypandy's Avatar
 
Join Date: Nov 2010
Location: Yo Momma :P (Im SO Funny)
Posts: 73
andypandy is on a distinguished road

Javascript help needed!


Hi guys, I'm doing GCSE Computing and I am making a website. For our homework we have to make to radio buttons to select whether we are male or female then we have an alert box when clicking submit saying "You have chosen (male/female)" or if nothing is selected it needs to say " Please select your gender."

Here is my code so far which does include some alerts but it isn't the same var things for radio box:

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>FunnyFings.com</title>

<script>

function validateform()
{
var x=document.forms["myform"]["email"].value;
var xlength=document.forms["myform"]["email"].value.length;
var y=document.forms["myform"]["password"].value;
var ylength=document.forms["myform"]["password"].value.length;


if (x==null || x=="")
{
alert("Email Address must be filled out");
}

if ((xlength<"5") || (xlength>"25"))
{
alert("Email Address must contain between 5 and 20 characters");

myform.fname.focus();
return (false);
}

if (y==null || y=="")
{
alert("Password must be filled out");
}

if ((ylength<"3") || (ylength>"10"))
{
alert("Password must contain between 3 and 10 characters");

myform.fname.focus();
return (false);
}

}



</script>



</head>

<body bgcolor="#FF9900" >

<marquee BGcolor="#66FF00" direction="right">
<center>
Welcome To FunnyFings.com
</center>
</marquee>

<form name="myform">
<br />
Email Address <input type="text" name="email" />
<br />
<br />
Password: <input type="password" name="password" />
<br />
<br />
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
<br />
<br />
Favourite Colour:
<select name="favourite colour">
<option value="orange">Orange</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
</select>
<br />
<br />
<input type="checkbox" name="check box"/> I have read the non-existent Terms and Conditions.
<br />
<br />
<input type="button" name="button" value="Subscribe" onclick="validateform()"/>
</form>

</body>



</html>
__________________
 
Reply With Quote
Old 31-10-11, 09:08 PM   #2
iPod 30gb
 
Join Date: Aug 2009
Location: Widnes
Posts: 1,090
cono1717 is a jewel in the rough
Just add a new variable

Code:
var g=document.forms["myform"]["sex"].value;
Then you need to check if "g" is null and if not display an alert telling them what it is.
__________________
Totally Free iPad | McFlurry Ice Cream Van

Everything I say reflects my own opinions and not that of any company.

Last edited by cono1717; 31-10-11 at 09:08 PM..
 
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off





All times are GMT. The time now is 09:02 PM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts