hi all,
i am having problem with javascript validation..My problem is i am having two radio buttons
1.Single
2.Married
By default single is checked.Now when we select married i will get displayed spouse name below.Now if the person check married and didnt enter spouse name then i should get an alert. can any one help me..
Thank u..
<html>
<head>
function hideEnable(){
document.getElementById('numDiv').style.display = 'inline';
document.getElementById('spousename').style.display = 'inline';
}
function hidedisable(){
document.getElementById('numDiv').style.display = 'none';
document.getElementById('spousename').style.display = 'none';
}
</head>
<body>
<form name="myform" enctype="multipart/form-data" action="joiningform.php" method="post">
<table>
<tr>
<td align="right"> Marital Status : </td>
<td align="left">
<input type="radio" id="maritalstatus1" name="maritalstatus" value="single" onclick="return hidedisable();" checked="checked"/>
Single
<input type="radio" id="maritalstatus2" name="maritalstatus" onclick="return hideEnable();" value="married">
Married </td>
</tr>
<tr>
<td align="right">
<DIV id=numDiv DISPLAY: none">
<LABEL>Spouse Name:
</LABEL></td>
<td align="left">
<input id="spousename" type="text" name="spousename" style="display: none;" >
</td>
</td></DIV>
</tr>
</table>
</form>
</body>
<html>
i tried this but i didnt get..
if(document.getElementById("maritalstatus2").checked == true)
{
frmvalidator.addValidation("spousename","req","Please enter Spouse Name");
}