how to disable validation for ajax form reload

Member | 492

If i change selectbox, or change radiolist, or check checkbox, always it is a new state for form. And form muset be regenerated and as a snippet replaced.

But how to do it if i have validations. I have only one submit button.

Nothing works for me.

I have Nette 2.2.7

$button = $form->addSubmit('save', "");
result: Validation scope accepts only Nette\Forms\Container or Nette\Forms\IControl instances

but even if it would worked, i am afraid that submitting this form caused that javascript validation is triggered and it doesnt allow that the number would not be filled

next try

$form['number']->addConditionOn($form['save'], $form::SUBMITTED)->addRule($form::REQUIRED, 'adm.extensions.modal.numberValidation');

also it doesnt work

what next?

David Matějka
Moderator | 5609

You have to pass an array to the setValidationScope method, see doc



doesnt matter, it doesnt work in both cases? I mean yes, it works that there is no error, but the validation is still on.

4 years ago
Member | 1

You can prevent the form from submitting with

$(“#prospects_form”).submit(function(e) {
Of course, in the function, you can check for empty fields, and if anything doesn't look right, e.preventDefault() will stop the submit.

Member | 1

Add this onsubmit=“return false” code:

<form name=“formname” onsubmit=“return false”>
That fixed it for me. It will still run the onClick function you specify
Selenium Training in Chennai