Form validation for check boxes only seems to be working in IE....? Anyone have a sample of it working in FF?
Thanks.
Form validation for check boxes only seems to be working in IE....? Anyone have a sample of it working in FF?
Thanks.
Um...Your question isn't exactly a clear one.
If it's form validation as in checking then shouldn't you be doing this server side? Which would be browser independent.
If you are doing any form validation with Javascript and then passing it to the server you must always check it server side as well...a simple http request could easily mess up a system that doesn't.
If you have a Javascript library that you are using to validate forms then it might be an idea to provide more details.
Just checking on browser side for now. I do not have a JS library, would like to keep it as simple as possible. Like I said I am able to get basic JS functions to validate in IE (alert box if nothing is selected) but in FF it just goes past it and submits.
Using html for form, (js for validation onsubmit(form)....etc..)
var isChecked = document.forms['myform'].elements['mycheckbox'].checked;
if (!isChecked) {
alert('You must agree');
}
To obtain your element (checkbox) value, you can use something a bit more cross browser compatible....
var CheckBox = document.all ? document.all["checkbox"] : document.getElementById("checkbox"); var isChecked = CheckBox.checked;