mercredi 30 décembre 2015

checkbox validation in symfony2

I am creating a registration form in symfony2. I need to validate this checkbox, if a user has not checked this checkbox then there should be a client side validation.i have used client side validation also but it is not validating it.
This is my registration form type.

$builder->add('check', 'checkbox', array(
                    'label'     => 'I agree to terms and conditions',
                    'required'  => false,
                    'mapped' => false,
                    'value'=>false,
                    'translation_domain' => 'FOSUserBundle'));

This is my CLient side java script

var check = $("#fos_user_registration_form_check").val();
                    if(check!=1)
                    {
                        $("#msgCheck").html('Check the Box').css('color','red').show();
                        $error=true;
                    }else{
                        $("#msgCheck").hide();
                        $error=false;
                    }




Aucun commentaire:

Enregistrer un commentaire