|
Websites
|
|
Wednesday, 18 January 2012 14:23 |
Forms. As web developers, we work with them a lot. And you have to deal with validating them client-side and server-side. You can write custom javascript to do the client-side validation and then separate code for server-side validation. But what if the server finds and error that was not found client side, such as trying to register a user, but that username is already taken? So now you have to be able to not only validate on both sides, but display errors from both sources.
It's simple really, but I've finally decided that it's just easier to submit ALL forms via AJAX. The validation can all be done server-side because with an AJAX call it's pretty darn fast. In the end it's really much more simple. Plus, on most sites, you have some forms that submit "normally" and some that submit via ajax, so you have two general philosophies to support. Let's make life more simple. Just do it all via AJAX.
|