How do I make Javascript checkboxes than needs to be checked ? I have a site and I need something at the new user registration ( I agree with TOS ) and the TOS checkbox needs to be checked ... Hope you understand my request /edit : I found something related at DynamicDrive : http://www.dynamicdrive.com/dynamicindex16/acceptterm.htm It's not the same thing but it can do the job
That's pretty simple actualy. Here's one way to do it: <script type='text/javascript'> function enableConfirm(checked) { if(document.forms[0].check.checked == true) document.forms[0].confirm.disabled = ''; else document.forms[0].confirm.disabled = 'disabled'; } </script> <form method='post'> <input type='checkbox' name='check' onclick='enableConfirm(this.checked)'> <input type='submit' name='confirm' disabled> </form> Code (markup):
you can also use the document.getElementByID method function checkConfirm(chkID) { var chkBox = document.getElementById(chkID); return chkBox.checked } use it like this if( !checkConfirm('theCheckBoxID') ) { alert('your error goes here'); }