need help validating the radio buttons on this form ive tried different functions & different methods on the web but none work. code is this: also for the "Campus" radio buttons you need to be able to select 1 or more & im not sure if what ive done is correct, any help wud be greatly appreciated.
<script type="text/javascript">
function formValidator(){
var unitnum = document.getElementById('unitnum');
var unitnam = document.getElementById('unitnam');
var unitconame = document.getElementById('unitconame');
var roomnumber = document.getElementById('roomnumber');
var building = document.getElementById('building');
var phonenum = document.getElementById('phonenum');
if(isNumeric(unitnum, "Please enter a valid unit number")){
if(lengthtotal(unitnum, 6)){
if(isAlphabet(unitnam, "Please enter only letters for your unit name")){
if(lengthRestriction(unitnam, 1, 50)){
if(isAlphabet(unitconame, "Please enter only letters for your coordinator name")){
if(lengthRestriction(unitconame, 1, 50)){
if(isAlphanumeric(roomnumber, "Numbers and Letters Only for room number")){
if(lengthRestriction(roomnumber, 1, 10)){
if(isAlphanumeric(building, "Numbers and Letters Only for building")){
if(lengthRestriction(building, 1, 15)){
if(isNumeric(phonenum, "Please enter digits for Phone number")){
if(lengthtotal(phonenum, 10)){
return true;
}
}
}
}
}
}
}
}
}
}
}
}
return false;
}
function isEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus();
return true;
}
return false;
}
function isNumeric(elem, helperMsg){
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphabet(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphanumeric(elem, helperMsg){
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function lengthRestriction(elem, min, max){
var uInput = elem.value;
if(uInput.length >= min && uInput.length <= max){
return true;
}else{
alert("Please enter " +min+ " and "+max+" characters");
elem.focus();
return false;
}
}
function lengthtotal(elem, total){
var uInput = elem.value;
if(uInput.length == total){
return true;
}else{
alert("Please enter " +total+ " digits");
elem.focus();
return false;
}
}
</script>
</head>
<body>
<h1>Unit Information Form</h1>
<h3>Please Fill Out Form</h3>
<p><a href="default.htm"> Back |</a><a href="assessments.htm"> Assessments </a></p>
<fieldset>
<form action="http://tl28serv.uws.edu.au/iwsdinfo/form.asp" name="valform" onsubmit='return formValidator()'
method="post">
<p>Unit Number:
<input type="text" name="unitnum" /><br /><br />
Unit Name:<input type="text" name="unitnam" /></p>
<p>Campus<br />
<input type="radio" name="campus1" value="campbelltown" /> Campbelltown
<br />
<input type="radio" name="campus2" value="parramatta" /> Parramatta
<br />
<input type="radio" name="campus3" value="penrith" /> Penrith
</p>
<p>Unit Level<br />
<input type="radio" name="unitlvl" value="one" /> 1
<br />
<input type="radio" name="unitlvl" value="two" /> 2
<br />
<input type="radio" name="unitlvl" value="three" /> 3
</p>
<p>Semester<br />
<input type="radio" name="semester" value="Autumn" /> Autumn
<br />
<input type="radio" name="semester" value="Spring" /> Spring<br />
</p>
<p>Unit Coordinator:<br />
Name:
<input type="text" name="unitconame" /><br />Location:<br />
Room Number: <input type="text" name="roomnumber" /><br />
Building: <input type="text" name="building" /><br />
Campus:<br />
<input type="radio" name="unitcocampus" value="campbelltown" /> Campbelltown
<br />
<input type="radio" name="unitcocampus" value="parramatta" /> Parramatta
<br />
<input type="radio" name="unitcocampus" value="penrith" /> Penrith<br />
Phone Number: <input type="text" name="phonenum" /><br />
Email Address: <input type="text" name="email" /><br /><br />
<input type="submit" value="Submit" /> <input type="reset" value="Reset" />
</p>
</form>
</fieldset>
</body>
</html>