if (document.myFormName.myRadioName.checked &&
!document.myFormName.myTextName.value) {
alert("Please enter text."
} =========================================================
if (!succeed) try();
-jeff
hi, that code generates this error:
line 28:
document.Form has no properties.
This is what I put in the header:
<SCRIPT language=JavaScript>
<!-- Begin
if (document.Form.F1.checked &&
!document.Form.F2.value) {
alert("Please enter text."
}
// End -->
form would be the name of your form. if you named it form then rename it _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
Another question, How would this script differentiate between the radio buttons. WHat I mean is this , it is one question with 4 selections so, since they are radio buttons they are all F1, if the user chooses that last radio button "other" I want the text box to be mandatory.
you need to loop through the radio buttons and find out which has been selected and then perform your conditioning
example written in here
thread215-468144 _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
alrighty,
alrighty,
let's say you have 4 radios buttons named F1
<input type="radio" name="F1" value="A"> A <br>
<input type="radio" name="F1" value="B"> B <br>
<input type="radio" name="F1" value="C"> C <br>
<input type="radio" name="F1" value="other"> other <br>
add a button to see if they selected whatever
<input type="button" value="check" onClick="runFunction()">
now you need to loop through the radios in your function first to figure out what you have selected
function runFunction()
{
var radios = document.formname.F1
for( x=0; i < radios.length; x++)
if( radios[x].checked) {
var selectedRadio = radios[x].value;
//test it
alert(selectedRadio);
}
}
now you have something to work off of.
if(selectedRadio == "other" {
perform the manditory condition
}
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
ha!!!
I did it again, well not really copy/paste form the otehr thread and forgot to fix the i thing
change this line
for( x=0; i < radios.length; x++)
to
for( x=0; x < radios.length; x++)
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.