Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using econditionalvalidator with checkbox and dropdown #24

Open
srakl opened this issue Jan 27, 2015 · 0 comments
Open

using econditionalvalidator with checkbox and dropdown #24

srakl opened this issue Jan 27, 2015 · 0 comments

Comments

@srakl
Copy link

srakl commented Jan 27, 2015

i have a checkbox is_new that when checked will enable a dropdown #Dealership_make_code

basically i'm trying to get my error checking to validate and make sure a dropdown option has been selected if the checkbox is checked.

If checkbox is NOT checked, dropdown can be empty. Here is my code

 array(
                'make_code', 'site.common.components.validate.EConditionalValidator',
                'conditionalRules' => array('is_new', 'compare', 'compareValue' => 1),
                'rule' => array('required'),
                'clientValidationJS' => "if ($('#Dealership_is_new :checkbox:checked').length > 0) {
                                            if ($('#Dealership_make_code').val().length === 0) {
                                                    alert($('#Dealership_make_code').val().length);
                                                    messages.push('cannot be empty');
                                                }
                                            }
                                         "      
            ),

i cant seem to get this to work, nor can i get the client side to work either. Any idea what i'm missing? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant