![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
If you have <input> elements with the same name then the browser document object model reflects them as an array thus you need to check f.myoption[0].disabled f.myoption[1].disabled |
|
I have a page in which sometimes radio buttons are disabled although this is not the normal case. On the radio buttons that may be disabled, I have javascript validation ensuring other fields are filled out when they are not disabled. But I do not want this validation to occur when the radio buttons are disabled. The radio buttons look like this: input type="radio" name="myoption" value="0" >Option 1 input type="radio" name="myoption" value="1" checked>Option 2 and the form has the onsubmit validation: form name="myForm" method="post" action="xxx.asp" onSubmit="return checkDetails(this)" And the javascript for checkDetails looks like this: (f is the input parameter i.e "this" or the form) if (f.blnBTDialin == null) { return true; } else if (f.myoption.disabled == true) { return true; } else if Boolean(<%=aspvalue%>) && f.myoption[1].checked && f.detail1.checked ) { alert ("Sorry, blah blah blah.") return false; } else { if (f.myoption[1].checked && f.detail1.checked == true && f.detail2.checked == false) { alert ("You must select detail2.") return false; } } I have two problems, at first I did not have the line containing (f.myoption.disabled == true) because I thought the remaining conditions would fail if the field was disabled. But if the field is disabled and even if myOption[0] is selected, the code falls through to the "You must select detail2" clause. So I added the test on the disabled property, but this property always comes up as undefined, whether the radio buttons are disabled or not. This is the case also if I try typeof(f.myoption.disabled) |
![]() |
| Thread Tools | |
| Display Modes | |
| |