Javascript radio button issue -
im trying validate gender radio buttons. works if not selected, when 1 selected still says "gender not selected"..does know how around this?
i have..
if (!gendermaleradiobutton.checked || !genderfemaleradiobutton.checked) { errormessage = errormessage + "gender not selected\n"; } //displays error messages if (errormessage) { alert(errormessage); } //if information valid, submission success. else if(!errormessage) { alert("submission successful, thank " + firstname.value); }
you saying "if male button not pressed or female button not pressed, display error message." change first line
if(!gendermaleradiobutton.checked && !genderfemaleradiobutton.checked)
,
makes "if male button not pressed , female button not pressed, display error message."
Comments
Post a Comment