Difference between #1 and #2 of
How To: Custom Client Validation On Checkbox Toggle and Optional Input Field

Revision #2 has been created by Wade Shuler on Jul 5, 2016, 9:28:17 AM with the memo:

fix heading tag
« previous (#1)

Changes

Title unchanged

How To: Custom Client Validation On Checkbox Toggle and Optional Input Field

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

yii2, form, model, model validation, Form validation, ClientValidation, client-side, whenclient, rules, validation rules, javascript, jquery

Content changed

[...]
You **do not** need to reset the status of all the inputs on your form.

You **do not** need to set the "submitting" value to true, as illustrated in the Yii2 Cookbook (linked to from the Yii2 docs on Client Validation).


##
# Use Case

You have a form with a checkbox and a text input. The checkbox is not required, but if it is checked, the text input should then be required. If the checkbox is un-checked, the text input should no longer be required. In my case, it is for using Gravatar for user profile pics. If they have Gravatar, they check the box and enter in their Gravatar email address (since it may not match the email they used to register on my site). Later, I will be pairing it with cebe's yii2-gravatar extension. It is actually quite simple :)

**Model:**
[...]
0 0
1 follower
Viewed: 23 146 times
Version: 2.0
Category: How-tos
Written by: Wade Shuler
Last updated by: Wade Shuler
Created on: Jul 5, 2016
Last updated: 7 years ago
Update Article

Revisions

View all history