{"id":9333,"date":"2022-10-06T04:57:47","date_gmt":"2022-10-06T04:57:47","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9333"},"modified":"2022-10-06T04:57:47","modified_gmt":"2022-10-06T04:57:47","slug":"html-forms","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/html-forms\/","title":{"rendered":"HTML Forms"},"content":{"rendered":"\n<p>An HTML form is composed of form elements, which are different kinds of input elements, such as checkboxes, text fields, submit buttons, radio buttons, and so on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-html-lt-input-gt-element-2\">The HTML &lt;input&gt; element<\/h2>\n\n\n\n<p>The\u00a0&lt;input>\u00a0element is an essential form element, which, depending on the\u00a0type\u00a0attribute, can be displayed in different ways.<\/p>\n\n\n\n<p>Let\u2019s speak about some of input types.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"text-input-4\">Text input<\/h3>\n\n\n\n<p>The&nbsp;<kbd>&lt;input&nbsp;type=\"text\"&gt;<\/kbd>&nbsp;specifies a one-line input field for text input.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-text-input-6\">Example of the text input:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h2&gt;Text Input Example&lt;\/h2&gt;\n    &lt;form&gt;\n      Name:&lt;br&gt;\n      &lt;input type=\"text\" name=\"name\"&gt;\n      &lt;br&gt;\n      Surname:&lt;br&gt;\n      &lt;input type=\"text\" name=\"surname\"&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"radio-button-input-8\">Radio Button Input<\/h3>\n\n\n\n<p>The&nbsp;<kbd>&lt;input&nbsp;type=\"radio\"&gt;<\/kbd>&nbsp;specifies a radio button with the help of which you can select one of many choices.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-radio-button-input-10\">Example of the radio button input:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h2&gt;Radio Button Example&lt;\/h2&gt;\n    &lt;form&gt;\n      &lt;input type=\"radio\" name=\"game\"value=\"football\" checked&gt; Football\n      &lt;input type=\"radio\" name=\"game\" value=\"basketball\"&gt; Basketball\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"submit-input-12\">Submit input<\/h3>\n\n\n\n<p>The&nbsp;<kbd>&lt;input&nbsp;type=\"submit\"&gt;<\/kbd>&nbsp;submits the form data to a form-handler.<\/p>\n\n\n\n<p>The form-handler is a server page with a script to process input data, which is defined in the&nbsp;action&nbsp;attribute of the form.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-submit-input-14\">Example of the submit input:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h2&gt;HTML Form Example&lt;\/h2&gt;\n    &lt;form action=\"\/form\/submit\" method=\"POST\"&gt;\n      Name:&lt;br&gt;\n      &lt;input type=\"text\" name=\"firstname\" value=\"Tom\"&gt;\n      &lt;br&gt;\n      Surname:&lt;br&gt;\n      &lt;input type=\"text\" name=\"lastname\" value=\"Brown\"&gt;\n      &lt;br&gt;\n      Age:&lt;br&gt;\n      &lt;input type=\"text\" name=\"Age\" value=\"21\"&gt;\n      &lt;br&gt;&lt;br&gt;\n      &lt;input type=\"submit\" value=\"Submit\"&gt;\n    &lt;\/form&gt;\n    &lt;p&gt;Click the \"Submit\" button, to sent the form-data to the action page.&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-action-attribute-16\">The Action Attribute<\/h2>\n\n\n\n<p>The&nbsp;action&nbsp;attribute specifies the action that should be performed when the form is submitted.<\/p>\n\n\n\n<p>When the user the form data is sent to a web page on the server when the user clicks on the submit button.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form action=\"\/form\/submit\"&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-target-attribute-19\">The Target Attribute<\/h2>\n\n\n\n<p>The&nbsp;target&nbsp;attribute defines whether the form result is open in a new browser tab, frame, or in the current window.<\/p>\n\n\n\n<p>The default value of this attribute is&nbsp;<kbd>_self<\/kbd>. Using this value will open the form result in the current window.<\/p>\n\n\n\n<p>The&nbsp;<kbd>_blank<\/kbd>&nbsp;value will open the form result open in a new browser tab.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form action=\"\/form\/submit\" target=\"_blank\"&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-method-attribute-22\">The Method Attribute<\/h2>\n\n\n\n<p>The&nbsp;method&nbsp;attribute defines the HTTP method (GET or POST) that will be used when submitting the form data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-span-class-attribute-get-span-method-24\">Example of the&nbsp;GET&nbsp;method:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h2&gt;The method Attribute With the GET Method&lt;\/h2&gt;\n    &lt;form action=\"\/form\/submit\" target=\"_blank\" method=\"GET\"&gt;\n      Neame:&lt;br&gt;\n      &lt;input type=\"text\" name=\"name\" value=\"Tom\"&gt;\n      &lt;br&gt;\n      Surname:&lt;br&gt;\n      &lt;input type=\"text\" name=\"Surname\" value=\"Brown\"&gt;\n      &lt;br&gt;\n      Age:&lt;br&gt;\n      &lt;input type=\"number\" name=\"Aage\" value=\"21\"&gt;\n      &lt;br&gt;&lt;br&gt;\n      &lt;input type=\"submit\" value=\"Submit\"&gt;\n    &lt;\/form&gt;\n    &lt;p&gt; Here we used the \"_blank\" value, which will open the form result in a new browser tab.&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-span-class-attribute-post-span-method-26\">Example of the&nbsp;POST&nbsp;method:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h2&gt;The method Attribute With the Post Method&lt;\/h2&gt;\n    &lt;form action=\"\/form\/submit\" target=\"_blank\" method=\"POST\"&gt;\n      Name:&lt;br&gt;\n      &lt;input type=\"text\" name=\"name\" value=\"Tom\"&gt;\n      &lt;br&gt;\n      Surname:&lt;br&gt;\n      &lt;input type=\"text\" name=\"surname\" value=\"Brown\"&gt;\n      &lt;br&gt;\n      Age:&lt;br&gt;\n      &lt;input type=\"number\" name=\"age\" value=\"21\"&gt;\n      &lt;br&gt;&lt;br&gt;\n      &lt;input type=\"submit\" value=\"Submit\"&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"when-to-use-the-get-method-28\">When to use the GET Method<\/h2>\n\n\n\n<p>GET&nbsp;is the default method when submitting form data, and when using this method the form data is visible in the page address field.<\/p>\n\n\n\n<p>Don\u2019t use the GET method to send sensitive data, because it will be visible in the URL.<\/p>\n\n\n\n<p>The GET method is useful for form submissions where a user wants to bookmark the result.<\/p>\n\n\n\n<p>The length of a URL is limited (maximum 2048 characters).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"when-to-use-the-post-method-33\">When to use the POST Method<\/h2>\n\n\n\n<p>If the form data includes sensitive or personal information, always use the POST method, as it doesn\u2019t display the submitted form data in the page address field.<\/p>\n\n\n\n<p>As there are no size limitations while using the POST method, it can be used to send large amounts of data.<\/p>\n\n\n\n<p>Form submissions with the POST method can\u2019t be bookmarked.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"other-attributes-37\">Other Attributes<\/h2>\n\n\n\n<p>Below you can find other &lt;form&gt; attributes:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Attribute<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>accept-charset<\/td><td>This attribute defines the charset that is used in the submitted form (default: the page charset).<\/td><\/tr><tr><td>autocomplete<\/td><td>This attribute defines whether the browser should autocomplete the form or not (default: on).<\/td><\/tr><tr><td>enctype<\/td><td>This attribute defines the encoding of the submitted data (default:url-encoded).<\/td><\/tr><tr><td>name<\/td><td>This attribute defines a name that is used to identify the form.<\/td><\/tr><tr><td>novalidate<\/td><td>This attribute defines that the browser must not validate the form.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>An HTML form is composed of form elements, which are different kinds of input elements, such as checkboxes, text fields, submit buttons, radio buttons, and so on. The HTML &lt;input&gt; element The\u00a0&lt;input>\u00a0element is an essential form element, which, depending on the\u00a0type\u00a0attribute, can be displayed in different ways. Let\u2019s speak about some of input types. Text [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[325],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9333"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9333"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9333\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}