I am trying to write a page that requires a Pass/Fail for conditions that are done everyday and then posting them to a database. The problem I'm having is the validation of the checkboxes. Find the code below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
#form1 {
text-align: left;
width: 550px;
margin-left: 0px;
}
</style>
</head>
<script language="javascript">
function validate()
{
var chks = document.getElementsByName('dailycheck');
var checkCount = 0;
for (var i = 0; i < chks.length; i++)
{
if (chks.checked)
{
checkCount++;
}
}
if (checkCount < 8)
{
alert("Please select Pass or Fail for each.");
return false;
}
return true;
}
</script>
<body style="margin-left: 350px; margin-top: 60px">
<form name="form1" onSubmit="return validate()">
<table style="width: 81%; text-align: left">
<tr>
<td style="width: 285px">Called 512-483-9014</td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px"/>Fail
</td>
</tr>
<tr>
<td style="width: 285px">Called 512-381-0115</td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px">Checked VLPortal for Calls since Midnight</td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
</table>
<table style="width: 81%; text-align: left">
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</table>
<p style="width: 52px; margin-left: 280px">
<input name="Submit" type="submit" value="Formsubmit1" style="text-align: center; margin-left: 0px" /></p>
<p> </p>
</form>
</body>
</html>
Multiple checkbox validation is new to me and I'm just needing some help in the correct direction to go. Can anyone assist me please?
Thank you
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
#form1 {
text-align: left;
width: 550px;
margin-left: 0px;
}
</style>
</head>
<script language="javascript">
function validate()
{
var chks = document.getElementsByName('dailycheck');
var checkCount = 0;
for (var i = 0; i < chks.length; i++)
{
if (chks.checked)
{
checkCount++;
}
}
if (checkCount < 8)
{
alert("Please select Pass or Fail for each.");
return false;
}
return true;
}
</script>
<body style="margin-left: 350px; margin-top: 60px">
<form name="form1" onSubmit="return validate()">
<table style="width: 81%; text-align: left">
<tr>
<td style="width: 285px">Called 512-483-9014</td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px"/>Fail
</td>
</tr>
<tr>
<td style="width: 285px">Called 512-381-0115</td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px">Checked VLPortal for Calls since Midnight</td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
</table>
<table style="width: 81%; text-align: left">
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</tr>
<tr>
<td style="width: 285px"> </td>
<td>
<input name="dailycheck" type="checkbox" value="pass" style="width: 23px" />Pass
<input name="dailycheck" type="checkbox" value="fail" style="width: 23px" />Fail
</td>
</table>
<p style="width: 52px; margin-left: 280px">
<input name="Submit" type="submit" value="Formsubmit1" style="text-align: center; margin-left: 0px" /></p>
<p> </p>
</form>
</body>
</html>
Multiple checkbox validation is new to me and I'm just needing some help in the correct direction to go. Can anyone assist me please?
Thank you