HiExperts,
I am creating a form with a javascript validation function for a radio group. The idea is, when “None” is checked, no div pop up, and when “Monday” or “Tuesday” is checked, a div pop up:-
//the form
<form name="form_sf" id = "form_sf" method="post" action="process.php" onSubmit="return check_sf_form_info(form_sf,'all')">
<input name="date" id="date" type="radio" value="nil" onChange="check_sf_form_info(form_sf,2)" />None
<input name="date" id="date" type="radio" value="mon" onChange="check_sf_form_info(form_sf,2)" />Monday
<input name="date" id="date" type="radio" value="tue" onChange="check_sf_form_info(form_sf,2)" />Tuesday
</form>
//the javascript
function check_sf_form_info(form,mark,edit){
if(mark==2 || mark=="all"){
if(form.date.value!=="nil"){
price.innerHTML="$100";
price.style.display="block";
price.style.height="auto";
}else{
price.innerHTML="";
price.style.display = "none";
}
}
}
Would experts please teach me where I have done wrongly? Thanksalot!
The nil radio button is the first item in the radio groups.
therefore you can use ‘getElementsByName’ functions.