Wednesday, 16 September 2015

Learn About Html Forms

Html Forms:

<form> Element:

Html forms are used to collect user input.
<form> element defines Html form;

Html forms contain form elements.
Form elements are of different types input elements,checkboxes,submit buttons and more.

<input> Element:

<input> element is most important form element.
<input> element has many variation depending on type attribute.

Types that are used in this chapter:


Text Input In Html:

<input type="text"> defines one-line firld for text input;

Radio Button Input In Html:

To define radio button <input type="radio"> is used.
Radio buttons let user to select one limited number of choices;

Example:


Submit Button In html:

To define button for submitting form to a form-holder  <input type="submit"> is used.
Form-handler is typically server page with script for processing input data.
Form-handler is specified in form action attribute;

Example:


Action Attribute:

Action attribute defines action to be performed when form is submitted.
Common way to submit form to server is by using submit button.
Form is submitted to web page on web server.
In example, above server sside is specified to handle submitted form:

If action attribute is omitted action is set to current page.

Method Attribute:

Method attribute specifies HTTP method(GET or POST) to be used when submitting forms:

OR

When GET is To Be Used?

You can use it in default method;
If form submission is passive (like search engine query), and without sensitive information.
Form data will be visible in page address,When you use GET.

When You Should Use Post?

You should use post,If form is updating data,or includes sensitive information (password).
POST gives best security because submitted data is not visible in page address.

Name Attribe:

To submit correctly each input field must have a name attribute.
Example below will only submit "Last name" input field;

Example:


With <fieldset> Grouping Form Data:

<fieldset> element groups related data in a form.
<legend> element defines caption for <fieldset> element.

Example:


Html Form Attributes:

Html <form> element,with all possible attributes set will loke like:

<form> Attribute List:


No comments:

Post a Comment