mrsquash Posted October 9, 2007 Share Posted October 9, 2007 Hello, I have the following check that verifies whether or not a set of radio buttons are checked or not. This works great when neither of them are checked, but when one is checked it throws me this error: Error: 'document.inputForm.radio' is null or not an object if (!document.inputForm.radio[0].checked && !document.inputForm.radio[1].checked) { alert("Please make sure a radio button is checked."); return; } Quote Link to comment Share on other sites More sharing options...
localhost1 Posted October 10, 2007 Share Posted October 10, 2007 first pls tell me what do u want to do Quote Link to comment Share on other sites More sharing options...
mrsquash Posted October 10, 2007 Author Share Posted October 10, 2007 I have "Yes" and "No" radio buttons with the same object name. If neither button is checked I want it to display an error as you can see in my previous post. And this part works fine. BUT, as soon as one button is checked, it should continue processing the form, but instead I get the error message that you see in my previous post. Quote Link to comment Share on other sites More sharing options...
localhost1 Posted October 10, 2007 Share Posted October 10, 2007 you use logical or instead of logical and. change above code to f (!document.inputForm.radio[0].checked || !document.inputForm.radio[1].checked) Quote Link to comment Share on other sites More sharing options...
mrsquash Posted October 10, 2007 Author Share Posted October 10, 2007 But, since they are the same object name, only one can be checked at a time, if I use a logical or || that would mean it would display the error all the time since only one option can be checked at a time, correct? Quote Link to comment Share on other sites More sharing options...
mrsquash Posted October 10, 2007 Author Share Posted October 10, 2007 Wow, if anyone has a "Stupid" stamp, please apply it to my forehead! The code I had was correct...I just didn't notice a missing letter in my form name...sigh Quote Link to comment 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.