Answer the question
In order to leave comments, you need to log in
How to properly validate forms?
For a long time I was looking for how to do validation, but I did not find what I needed. I am interested in the correct validation on medium-sized sites, as well as on landing pages (I wonder if the validation methods differ at all depending on the scale of the project). Now about everything in order.
Firstly, how correct would it be to make a single validation logic for the entire site? Those. make handlers for the fields and hang them on the class or on the name attribute (how much is it right to hang on name, and not id, for example, and why), so that validation is applied throughout the site. I talked with an experienced developer and he said that they do validation for each form (why??? After all, you can forget about some field for example =)), and that assigning id fields is cool (it’s also very interesting why, because id in fact, it’s generally a bad tone and what if there are 2 identical forms on page 1 .. Then the second one will also have to do other id).
2. Is it good to use js plugins or is it better to do it yourself, again, according to a cool developer, it's EASIER to do it yourself .. What do you say?
3. How is the response from the server usually handled? Now I send a request to the controller (I use laravel) and pass the status to the view, depending on which different messages are displayed. Those. in case of an error, the server gives a view with an error. Is it better to do this or send some kind of status to the client so that it can be processed there on js?
If you have read it, then thank you very much =) I will be glad to have any thoughts!
Answer the question
In order to leave comments, you need to log in
they do validation for each form (why??? After all, you can forget about some field, for example =))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question