How to validate Symfony 2 form on client side (javascript)

I am new to symfony 2 and I am trying to create a standard form that needs to be verified by the server and navigator.

Server-side validation works fine with statements like @Assert\... , but I cannot find a way to make this work on the client side.

After searching, I pointed out that Symfony 2 does not have a javascript library to manage this ..

So my question is: what is the easiest way to do this?

I know that you can use a client-side library, like the jQuery Validation plugin or something like Regula , but that means that I have to duplicate my validation rules.

+6
source share
2 answers

Symfony is a PHP framework, i.e. the server infrastructure of an application. It does not provide client side validation unless you use HTML5 with the required attribute and a different type of email for input (this is still not very well implemented in browsers).

So, you need to find your own solution and try to connect it before Symfony2 to make it as simple as possible ... or find an existing package, for example APYJsFormValidationBundle

+7
source

This is the new Symfony 2 package that provides a client-side validation implementation for Symnfony types (forms) https://github.com/formapro/JsFormValidatorBundle

0
source

All Articles