I am putting together a generic form for registration of individuals and legal entities and the definition starts from two RadioButton's
that changes the fields, after they are filled they are sent to a Servlet
and then to a DAO
class, the form has different CPF fields for PF and CNPJ for PJ, I have a condition in Servlet
that needs to validate the selected type to be able to play the fields in class Usuario()
and I want to know how can I validate this in JSP from the radio button?
Basic structure:
<form>
<!-- Tipo de Cadastro -->
<input id="radiopf" type="radio" name="Type" checked value="pessoaPF">
<label for="radiopf">Pessoa Fisica</label>
<input id="radiopj" type="radio" name="Type" value="pessoaPJ">
<label for="radiopj">Pessoa Juridica</label>
</form>
<!-- Formulário de Cadastro -->
<form id="frm" name="FormCadastro" action="Controle" method="POST">
<fieldset id = "PF">
<!-- Campos Pessoa Física -->
</fieldset>
<fieldset id = "PJ">
<!-- Campos Pessoa Jurídica-->
</fieldset>
<input type="submit" value="Gravar" name="Cadastrar" onclick="return Validate();" />
</form>
is a validation in Validate();
made before sending data to JavaScript
checks data type, size, formatting, null fields, etc. strong> Servlet
is the Controle
that receives data via Servlet
to send to class request.getParameter()
.