Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard representation for HTML forms?

I am working on a system that needs to represent an html form with typical elements like text field, select box, labels etc but it can only speak JSON or XML, not HTML.

I could always write my own JSON or XML converter and parser to represent the form in the required format but I would like to stick to certain standard, if it exists, for change management and extensibility. Also, the standard must have an existing Javascript parser.

I was looking at XUL but it doesn't seem to have form tags and looks like a DSL suitable only for Mozilla based applications. Also I was unable to find a Javascript parser for the same.

I believe this should be a fairly common problem that somebody has solved but I'm unable to find it. Any pointers would be much appreciated.

like image 744
Chirantan Avatar asked Nov 17 '10 14:11

Chirantan


People also ask

How do you layout a form in HTML?

The elements used in an HTML form are check box, input box, radio buttons, submit buttons etc. Using these elements the information of an user is submitted on a web server. The form tag is used to create an HTML form.

Are HTML forms still used?

Form tags are still necessary if you want to be able to submit the form without AJAX (which may be useful in the early stages of development).

What is the use of forms in HTML Generally speaking and is applicable to all forms whatsoever?

An HTML form is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls.


1 Answers

The standard representation for HTML forms is... HTML forms.

As far as I know, no-one’s invented an alternative way to represent them because, well, why would you? They’re declarative already.

Thankfully, given that HTML can be written as XML (we call that XHTML), XHTML forms already satisfy your XML requirement.

As far as parsing them in JavaScript goes, it depends what you mean by parsing. John Resig is working on a full HTML parser in JavaScript, but if you’re just looking to read/write values via the DOM, you can do that in JavaScript.

The spec for HTML forms is here:

  • http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html

The spec for how to write HTML as XML is the XHTML 1.0 spec:

  • http://www.w3.org/TR/xhtml1/

If you’d rather use HTML5 forms, which adds some new form fields (see http://diveintohtml5.ep.io/forms.html), the relevant specs are:

  • HTML5 forms: http://dev.w3.org/html5/spec/forms.html#forms
  • HTML5 as XML: http://dev.w3.org/html5/spec/the-xhtml-syntax.html#the-xhtml-syntax
like image 67
Paul D. Waite Avatar answered Sep 27 '22 20:09

Paul D. Waite