dannybrazil Posted April 3, 2008 Share Posted April 3, 2008 Hello i want to make in my form a checkbox(for agree to terms) and i wrote this code : if (theForm.Checkbox2.value == "") { alert("Please check \"Terms of use\" field."); theForm.Checkbox2.focus(); return false; } but it doesnt work... what should i put in the "" thanks Quote Link to comment https://forums.phpfreaks.com/topic/99382-form-checkbox/ Share on other sites More sharing options...
rhodesa Posted April 3, 2008 Share Posted April 3, 2008 The value of the checkbox will always be 'on' (or whatever you specify it to be). To see if it's on/off, use the checked attribute: if (!theForm.Checkbox2.checked) { alert("Please check \"Terms of use\" field."); theForm.Checkbox2.focus(); return false; } Quote Link to comment https://forums.phpfreaks.com/topic/99382-form-checkbox/#findComment-508508 Share on other sites More sharing options...
dannybrazil Posted April 3, 2008 Author Share Posted April 3, 2008 working 10x Quote Link to comment https://forums.phpfreaks.com/topic/99382-form-checkbox/#findComment-508567 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.