HTML and CSS Reference
In-Depth Information
cause problems if it were placed in the URL of the web page in an unencoded state,
since forward slashes mean to move to a new directory on the web server. Instead, a for-
ward slash would be sent as %2F , which is the hexadecimal value assigned to a forward
slash in the UTF-8 character set. Even if the POST method is used to send the data, this
format will help pick out the form data from other information sent to the web server.
The time to change this attribute is when using a file input element (for uploading
files, which is described later), in which case this attribute should contain a value of
multipart/form-data , which allows the form to cope with binary data. The last
value, text/plain , sends the form data unencoded. This value generally should not
be used because it makes it difficult to pick out the form data. It is available mostly for
historical reasons.
The target attribute
The target attribute works like the target attribute found on links (the a element)
and tells the browser where to open the URL specified in the action attribute. The
value _blank will open the form submittal result in a new window, _self will open
it in the same window, and _parent will open it in the parent browsing context. For
instance, an iframe element could be used to embed an HTML page with a form in-
side another HTML page, which would be considered the nested HTML page's parent
browsing context. Lastly, the value of _top would load the page in the topmost page, if
the form were nested several pages deep (using multiple iframe s, for example).
The name attribute
The next attribute, name , is used to identify the form to scripts. It's essentially a
unique ID given to a form to identify it among all forms used on a page. In JavaScript,
forms can be accessed through the document.forms property, which contains a
reference to all forms on the page. For instance, for a form that has the attribute
name="contactform" , the JavaScript document.forms.contactform
could be used to access it. If you are not very familiar with JavaScript, just know that
you could use the id (or even class ) attribute to access a form as well, and that may
well be a better route to take toward interacting with a form from JavaScript.
The autocomplete and novalidate attributes
Finally, the last two attributes, autocomplete and novalidate , will be discussed
more later, but in brief they tell the browser whether to automatically fill in remembered
values in the form and whether to validate the form's input, respectively.
Search WWH ::




Custom Search