I’ve been using jQuery to build an ajax-heavy site. I typically use jQuery selectors to refer to individual INPUT/BUTTON/TEXTAREA/etc elements I want to interact with (or retrieve values from).
I just realized this morning that I haven’t used a FORM tag in ages – I just manipulate everything through ajax requests. My gut tells me this is not good, but on the other hand it’s not been an issue (and I don’t foresee it becoming one any time soon, all our current needs are met).
One thing to note: I’m not concerned with graceful degradation in absence of JavaScript (it’s a corporate LAN; all browser installs are tightly regulated and all users are known to have javascript). With that said, is there some reason I should start using the FORM tag that I’m just not seeing?
Yes, you should still be using form tags. If you want to be really technical, it’s probably a good idea to have a non-JavaScript fallback as well. But regardless of that, the main reason for continuing to use
<form>,<fieldset>,<legend>, and<label>is for accessibility compliance.Forms are really the sore spot when it comes to web accessibility. They need to be conducted perfectly for smooth operation with screen readers or other assistive technologies. In fact, according to ADA and Section 508 laws and regulations, all those tags are required when making forms online. Many people would argue that federal regulations only apply to government and state websites, but you can tell that to Target, who was sued over web accessibility issues.
Really, it’s a good idea to just obey the rules. And, personally, making the form submit with or without AJAX is pretty easy. For example, I currently have several forms that are imperative that they can be used with out without JavaScript. All the forms are validated and submit via JavaScript (Yes, they are secondarily validated through the PHP script too). The script the JavaScript submits to is the same page the regular form submits to via cURL. One process page for two different methods with the same results (delivered in JSON and decoded via jQuery or PHP’s
json_decode), just the JavaScript version is cleaner, elegant, and more seamless.In conclusion, I feel your users would benefit more from including the proper tags then excluding them, even if the benefits don’t feel obvious to you or them.