Should I use the FORM tag?

I am using jQuery to create ajax-heavy site. I usually use a jQuery selector to refer to individual INPUT / BUTTON / TEXTAREA / etc elements that I want to interact with (or retrieve values).

I realized this morning that I did not use the FORM tag in the age - I just manipulate everything through ajax requests. My gut tells me that this is bad, but on the other hand, it is not a problem (and I do not foresee that it will become one in the near future, all our current needs will be fulfilled).

One note: I'm not interested in graceful degradation in the absence of JavaScript (this is a corporate LAN, all browser settings are tightly regulated, and all users, as you know, have javascript). With that said, is there any reason I should start using the FORM tag that I just don't see?

+4
source share
4 answers

Yes, you should still use form tags. If you want to be really technical, it's probably a good idea to also have a backup other than JavaScript. But regardless of this, the main reason for continuing to use <form> , <fieldset> , <legend> and <label> for accessibility.

Forms are really a sore spot when it comes to Internet accessibility. They should be made perfect for smooth operation with screen readers or other assistive technologies. In fact, according to the laws and regulations of ADA and Section 508, all of these tags are necessary when creating forms on the Internet. Many people claim that federal rules only apply to state and state websites, but you can report it to the target site , which has been sued about Internet access issues.

Indeed, it is a good idea to simply obey the rules. And, personally, form design with or without AJAX is pretty simple. For example, I currently have several forms that are necessary so that they can be used without JavaScript. All forms are validated and submitted via JavaScript (yes, they are re-validated using a PHP script). The script, which is JavaScript, is the same page that the regular form submits via cURL. One page of the process for two different methods with the same results (delivered in JSON and decoded via jQuery or PHP json_decode ), only the JavaScript version is cleaner, more elegant and smoother.

In conclusion, I feel that your users will benefit more from including the correct tags and then excluding them, even if the benefits do not seem obvious to you.

+2
source

Well, form elements must go into ... forms, right? The HTML5 specification (and almost any HTML specification) does not require the presence of <input> elements and other <form> elements, but you don’t really have a form on your page unless you have indicated in the markup that there is actually a form.

I find it even easier for you to deal with form submissions if jQuery knows which form is also submitted, including.

In addition, you have users with JavaScript disabled. Even if you do not like these users, it is still important that your web application can handle "traditional" forms if they are not processed by jQuery / Ajax, etc.

+2
source

Yes.

When JavaScript is disabled, using <form> you can still send data to the server. Given valid HTML rules, FORM tags are required for form elements. In addition, accessibility tools, such as screen readers, can use FORM tags to provide users with additional information.

So you should use the FORM tag. :)

+1
source

The reason for using them is that you can use http://api.jquery.com/serialize/ and http://api.jquery.com/serializeArray/ on <form> to use HTTP messages easily and easily (as you already mentioned).

0
source

All Articles