how to add a form with a unique id on jquery?

Must I always have to add name and id attributes in form input tags?

  • Isn't just the "id" enough?

  • Answer:

    The "id" tag is used by CSS and JavaScript to assign styles and act on the input item.  Libraries like jquery use the id as a shortcut identifier, so it's generally useful to set. The "name" attribute of a form element is what actually gets sent by your web browser in the HTTP GET or POST submission/request to the web server.  If you leave it blank, you won't have a proper identifier tied to your content. You may, however, be using JavaScript to submit your forms via AJAX, meaning that you never send form variables via GET or POST through direct web browser submission.  In that case, the name field is unnecessary, although it's not great convention.

Joe Emison at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.