What can i do to validate the page with javascript, and where is the code that I 've used wrong. I've looked at other validater pages, and put together what I think it roughly should be. I've only done two fields in the script, but want to apply to the whole of the form. I think if I can get some guidance I could do the rest based on the first few fields.
But I know it's not working, and would like some help on it. By validation I mean that if I miss a field that is required an alert pops up and tells me I need to enter the details before letting me submit the form, for fields as well as checkboxes, radio buttons, dropdown lists etc
thanks in advance
<Html>
<Head>
<Title> The Form </Title>
<script language=javascript type=text/javascript>
function Validate(theform) {
var empty = "";
if (theform.fname.value == "")
empty += "Fill in Your first name!\n";
if (theform.email.value == "")
empty += "Enter your email address!\n";
if ( empty != ""){
alert("You have missed vital information!\n"
+empty
+"Please complete the form and re-submit");
}
}
</script>
</head>
<body bgcolor=#000000 Text=#FFFFFF Link=White Alink=Red Vlink=Yellow>
<h2><center><u>Join The Lich King Or Parish For All Eternity!</u></center></h2>
<P>Please Fill the form below <br>
<Form method="post" action="mailto:blogasfurry@hotmail.com">
<Surname <Input type=text size=21
name=sname>
<br>
First Name
<Input type=text size=30 name=fname>
<br>
Email
<Input type=text size=30 name=email>
<p>Enter Your Motto (Maximum of 10 words):
<INPUT NAME=slogan size=40 maxlenght=35
Value="Please Be Reasonable..">
<input type="hidden" name="Language" value="English">
<INPUT TYPE=HIDDEN NAME="MailingID" value="345768">
<p>Address<br>
<TextArea Rows=3 cols=35 wrap="physical" name=Address></TextArea>
<p>
<tr>
<td class="formElements"><div align="left">Have you ever played video games?</div></td>
<td class="formElements">No
<input name="Ever play" type="radio" value="No" >
Yes
<input name="Ever play" type="radio" value="Yes"></td>
</tr>
<p>
Which games do you enjoy playing the most?
<p>
<Input type=checkbox name=mags value="Byte">MMORPG<br>
<Input type=checkbox name=mags value="Byte">Action/Adventure<br>
<Input type=checkbox name=mags value="Byte">Shooting<br>
<Input type=checkbox name=mags value="Byte">Strategy<br>
<Input type=checkbox name=mags value="Byte">Flash<br>
<Input type=checkbox name=mags value="Byte">Browser<br>
<p>
Which of the following do you own?
<p>
<Input type=checkbox name=mags value="Byte">PC<br>
<Input type=checkbox name=mags value="Byte">Playstation, II or III<br>
<Input type=checkbox name=mags value="Byte">X-Box 360<br>
<Input type=checkbox name=mags value="Byte">Wii<br>
<Input type=checkbox name=mags value="Byte">Saga<br>
<Input type=checkbox name=mags value="Byte">Other<br>
<p>
What age group do you belong to?
<br>
<Input type=radio name=age value="Under_16">Under 16<br>
<Input type=radio name=age value="16_to_19">16 to 19<br>
<Input type=radio name=age value="20_to_24">20 to 24<br>
<Input type=radio name=age value="+_25">+25<br>
<p>
Please select your hobbies from the list that we provided<br>
<select Name=select_hobbies size=5 MULTIPLE>
<Option>Tv
<Option>Films
<Option>Music
<Option>Computer Games
<Option>Fishing
<Option>Hanging out with Friends and Family
<Option>Studying
<Option>Eating
<Option>Sleeping
<Option>Other
</select><p>
<B>How Much Money would You Spend On a Game?:</B> <BR>
<SELECT NAME="Number">
<OPTION SELECTED> £20
<OPTION> £30
<OPTION> £45
<OPTION> £50
<OPTION> More
</SELECT>
<p>
<p>
<a href="#top">Back to Top</a>
<p>
<Input type=submit value="submit">
<Input type=Reset value="Clear">
</form>
</Body>
</Html>

New Topic/Question
Reply



MultiQuote




|