For example, I want avoid errors if someone disables Javascript... I think my JS validation must be called by my PHP code...
I'd like know about design patterns or anti-design patterns.
I should clarify that I must use JS in my project and not tools like jQuery or Dojo
The problem is more often how to keep both validation identical on the client using JS and on the server using PHP. What i often do is i create my validation on the server only using PHP and i send the content through AJAX using jquery.
The server sees that request as an ajax request because i pass it a content-type and then it doesn't process anything, just validates and returns a JSON response saying everything is ok, or it sends back the error messages that jquery will have to show to the user.
Like you asked, it's only a design pattern, a way of doing. Implementing it is another story, there are tons of ways to do it.
Good luck
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