I want to reset all fields of a form using CakePHP framework.
What happens is the following, the register button is only enabled if the user checks the box to accept.
If he clicks the clean button, I want you to leave the text-type fields empty and also reset radio
and checkbox
.
The way I'm doing it only works to reset the text type, but I want to reset all types of form fields. Let's go part of it.
echo $this->Form->create('users');
echo $this->Form->input('name', array('label'=>'login'));
echo $this->Form->input('password', array('label'=>'senha'));
//checkbox para abilitar o cadastro
echo $this->Form->input('aceitar', array('label'=>'aceito realizar cadastro', 'name'=>'aceitar', 'onclick'=>'cadastrar.disabled!=checked'));
//botao cadastrar
echo $this->Form->submit('cadastrar', array('label'=>'Cadastrar', 'name'=>'cadastrar', 'onclick'=>'disabled=true'));
//reset
//da forma abaixo só desabilita o botão cadastrar e o checkbox continua marcado.
echo $this->Form->button('limpar', array('label'=>'limpar', 'onclick'=>'cadastrar.disabled=true'));
//ou desmarca o checkbox e o botão fica disponível.
echo $this->Form->button('limpar', array('label'=>'limpar', 'onclick'=>'aceitar.checked=false'));
The two forms above do not apply to me.
I want to uncheck checkbox
and disable the register button, I already tried to use two onclick
on the reset button, but it did not work.