Hello,

Personnel have the following code:

HTML Code:
<script type="text/javascript">
function mostraDiv(valor){
if(valor == "fisica"){
document.getElementById("fisica").style.display = "";
document.getElementById("juridica").style.display = "none";
document.getElementById("juridica").disable = "true";
document.getElementById("fisica").disable = "false";}
else if(valor == "juridica"){
document.getElementById("fisica").style.display = "none";
document.getElementById("fisica").disable = "true";
document.getElementById("juridica").style.display = "";
document.getElementById("juridica").disable = "false";}}
</script>

<table width="480" border="1" style="margin-left: 60px;"><tbody>
<tr class="radio">
<td width="200"></td>
<td width="260" scope="col"><strong>TIPO DE CADASTRO:</strong></td>
<td width="240" scope="col"><input type="radio" id="pf" name="selecionar" value="fisica" onChange="mostraDiv(this.value)" /><label for="pf">PESSOA FÍSICA</label></td>
<td width="70"><strong style="color:#818181">|</strong></td>
<td width="270" scope="col"><input type="radio" id="pj" name="selecionar" value="juridica" onChange="mostraDiv(this.value)"><label for="pj">PESSOA JURÍDICA</label></td>
</tr>
</tbody></table>

<table><tbody>
<form name="form2" method="post" action="{$smarty.server.PHP_SELF}">
<input type="hidden" name="register" value="true" />

<tr id="fisica">
<td class="fieldarea">CPF/MF:</td>
<td><input type="text" name="cpf[1]" value="" onpaste="return false;" id="cpf" maxlength="14" size="43" placeholder="Digite o seu CPF..."/></td>
</tr>

<tr style="display: none;" id="juridica">
<td class="fieldarea">CNPJ/MF:</td>
<td><input name="cnpj[1]" id="cnpj" value="" type="text" maxlength="18" size="43" placeholder="Digite o seu CNPJ..."></td>
</tr>

<tr>
<td width="150" class="fieldarea">Nome:</td>
<td><input type="text" name="firstname" value="Nome" class="large" placeholder="Digite o seu nome..."></td>
</tr>

<tr>
<td>
<button type="submit"><strong>Enviar</strong></span></button>
</td>
</tr>

</form>
</tbody></table>
I was wondering if someone could help me make a change, I want to disable an input according to the option chosen.

When selecting "PESSOA FISICA", it disables the input of the "PESSOA JURIDICA", and vice versa.

Another issue is that to submit the form and a validation error occurs, it is not with the person chosen fields open. That is, if I choose the "PESSOA JURIDICA", submit the form and an error occurs, it returns to the fields of the "PESSOA FISICA", is not in the fields of "PESSOA JURIDICA". I know I have to create a function type checked, but do not know how to do this.

I do not have much knowledge in java, just the basics. Could anyone help me do this? take much of this change.

Thanks in advance!