Does anyone know how to validate form on client-side using javascript. HTML5 validation it's not enough for me.
2 Answers
Comments
My recomendation will be that you use this plugin http://jqueryvalidation.org/, it's great and really easy to use. You'll have to write some minimal javascript or go with data-* elements. See this example http://jqueryvalidation.org/files/demo/custom-messages-data-demo.html
Here is an example of validation in an UserType class:
...
->add('email', 'text', array (
'required' => false,
'attr' => array (
'placeholder' => 'Email',
'class' => 'form-control',
**'data-rule-required' => 'true'**
)
...
3 Comments
user2799026
It's possible to use validation rules defined in Symfony2?
Luis Lopez
As far as I know, the answer is no, at least with jquery-validation. But I have never tried JsFormValidatorBundle.
Luis Lopez
Why the downvote?? The question is about js validation. 3 years ago, jquery-validation was a great!!!