Javascript form validation
Posted: Tue Oct 14, 2003 4:51 pm
Well, I have a form with dynamic checkboxes.
Before the user submits I want javascript to
check that at least one checkbox has been checked.
So far I havn't figured out a way to do this....
Here's some psudo-code that I've been working on...
Thanks for any help.
--pb
Before the user submits I want javascript to
check that at least one checkbox has been checked.
So far I havn't figured out a way to do this....
Here's some psudo-code that I've been working on...
Code: Select all
<html>
<head>
<title>Title</title>
<script type="text/javascript">
function valid()
{
if(document.the_form.checkboxї].checked != true)
{
alert("You must select at least one option to continue.")
return false;
}
}
</script>
</head>
<body>
<form name="the_form" method="post" action="" onsubmit="return valid();">
<table>
<tr><td><input type="submit" value="Create Record" /></td></tr>
<tr><td> </td></tr>
<tr>
<td>Check box 1</td>
<td><input type="checkbox" value="1" name="checkboxї]" /></td>
</tr>
<tr>
<td>Check box 2</td>
<td><input type="checkbox" value="2" name="checkboxї]" /></td>
</tr>
<tr>
<td>Check box 3</td>
<td><input type="checkbox" value="3" name="checkboxї]" /></td>
</tr>
</table>
</form>
</body>
</html>--pb