hi
is there script validation for check box
is there script validation for check box
Moderator: General Moderators
You mean, to make sure it's checked?
Javascript would be something like this:
Not checked, but it should be fine.
Javascript would be something like this:
Code: Select all
<script type="text/javascript">
function validate()
{
x = document.formname.getelementbyid(my_box).value;
if (x == 1)
{
document.formname.submit();
}
else
{
alert('Check the box!');
}
}
</script>
<form name="formname" action="submit.htm">
<input type="checkbox" id="my_box" name="box" value=1 />
<input type="button" value="submit" onclick="validate()" />
</form>