You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to force validate on a form before displaying a confirmation to the user.
So I've tried calling: $('#formId').yiiActiveForm('validate')
Which didn't appear to do much.
Then I tried to use the forceValidate option: $('#formId').yiiActiveForm('validate', true)
This validated everything as expected but immediately triggered the form submit which I don't want yet.
Looking at the code in yii.activeForm.js the validate function starts with: if (forceValidate) { $(this).data('yiiActiveForm').submitting = true; } ...
Is there a way to trigger validation of all fields in the form (and show error messages to the user) without submitting it?
Is it worth renaming the forceValidate parameter here to something like submitWhenValid so it's more obvious what it does or creating a second parameter so that we force all fields to be validated without submitting the form?
Q
A
Yii version
2.0.13
PHP version
7.0
Operating system
Windows 10
The text was updated successfully, but these errors were encountered:
I'm trying to force validate on a form before displaying a confirmation to the user.
So I've tried calling:
$('#formId').yiiActiveForm('validate')
Which didn't appear to do much.
Then I tried to use the forceValidate option:
$('#formId').yiiActiveForm('validate', true)
This validated everything as expected but immediately triggered the form submit which I don't want yet.
Looking at the code in yii.activeForm.js the validate function starts with:
if (forceValidate) { $(this).data('yiiActiveForm').submitting = true; } ...
Is there a way to trigger validation of all fields in the form (and show error messages to the user) without submitting it?
Is it worth renaming the forceValidate parameter here to something like submitWhenValid so it's more obvious what it does or creating a second parameter so that we force all fields to be validated without submitting the form?
The text was updated successfully, but these errors were encountered: