I'm new to symfony 2 and i'm trying to build a standard form which should be validated by the server and by the navigator.
Server-side validation works fine with assertions like @Assert\...
but i cannot find a way to get this working on client side.
After searching, i pointed out that Symfony 2 does not have a javascript
library to manage this..
So my question is : What's the easiest way to do this ?
I know the possibility of using client side library like jQuery Validation
plugin or something like Regula, but that would means that i have to duplicate my validations rules..
JavaScript provides facility to validate the form on the client-side so data processing will be faster than server-side validation. Most of the web developers prefer JavaScript form validation. Through JavaScript, we can validate name, password, email, date, mobile numbers and more fields.
HTML form validation can be done by JavaScript.
The Complete Full-Stack JavaScript Course!JavaScript provides a way to validate form's data on the client's computer before sending it to the web server. Form validation generally performs two functions. Basic Validation − First of all, the form must be checked to make sure all the mandatory fields are filled in.
Form validation is a “technical process where a web-form checks if the information provided by a user is correct.” The form will either alert the user that they messed up and need to fix something to proceed, or the form will be validated and the user will be able to continue with their registration process.
Symfony is a PHP framework, ie server-side application framework. It doesn't provide client-side validation unless you use HTML5 one with required
attribute and other email
type for input (that is still not very well implemented in browsers).
So you have to find your own solution and try to plug it in front of Symfony2 to make it as easy as possible... or find an existing bundle like APYJsFormValidationBundle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With