PDA

View Full Version : jetting a validating JS to go with current JS



aequitas
12-24-2009, 11:33 PM
I need to get an add on JS for this form to go with the current JS that is on it
I need the add on JS to Validate all the fields have been filled out and then pop up an error if any of the fields are not filled out

<FORM NAME="gather"><form onclick="return check(this);">
<fieldset>
</p>
<table width="200" border="0" cellpadding="10">
<tr>
<th scope="row"><p align="left" class="style1">First Name*</p>
<p>
<div align="left"><input type="text" name="data_NameFirstName2" id="data_NameFirstName2" value="[Fname]"/>
</p></th>
</tr>
<tr>
<th scope="row"><p align="left" class="style1">Last Name*</p>
<p>
<div align="left"><input type="text" name="data_NameLastName2" id="data_NameLastName2" value="[Lname]"/>
</p></th>
</tr>
<tr>
<th scope="row"><p align="left" class="style1">Phone*</p>
<p>
<div align="left"><input type="text" name="phone1" id="phone1" />
</p></th>
</tr>
<tr>
<th scope="row"><p align="left" class="style1">Email*</p>
<p>
<div align="left"><input type="text" name="email" id="email" />
</p></th>
</tr>
</table>
</p>
<p>

<p><span class="style5">Please confirm your contact information.</span>
<p><span class="style5"> (* = required) </span>
<br />
<br />
<span class="style1">
<input type = "radio" name = "rad1" value = "Contact me">

<strong> Please contact me</strong></span></p>
<p> <span class="style1">Please have my personal advisor</span></p>
<p class="style1">contact me as soon as possible. <br />
<br />
</p>
<p>
<span class="style1">
<input type = "radio" name = "rad1" value = "Send me more info">

<strong>Send me more info</strong> </span></p>
<p class="style1">I'm not ready to enroll yet, but</p>
<p class="style1">please continue to send me more</p>
<p class="style1">information and updates about </p>
<p class="style1">going back to school <br />
<br />
</p>
<p>
<span class="style1">
<input type = "radio" name = "rad1" value = "Remove me from your mailing list">

<strong> No thanks </strong></span></p>
<p class="style1"> Please remove me from your </p>
<p class="style1">mailing list. <br />
<br />
</p>
<label>
<input type = "button" value = "submit" onclick ="chkrads()">
</label>
</fieldset>
</form>






<script type = "text/javascript">
function chkrads() {
var chosen = "None";
var which = -1;
var len = document.gather.rad1.length;
for (i = 0; i < len; i++) {
if (document.gather.rad1[i].checked) {
chosen = document.gather.rad1[i].value;
which = i;
}
}
if (chosen == "None") {
alert("No Location Chosen");
}
else {

}
if (which == 0) {window.location = "http://www.hudsonsd.com/national2010/thankcontact.html"}
if (which == 1) {window.location = "http://www.hudsonsd.com/national2010/thanksend.html"}
if (which == 2) {window.location = "http://www.hudsonsd.com/national2010/thanknocontact.html"}

}


</script>

Thanks!