{"id":7922,"date":"2021-08-13T12:08:53","date_gmt":"2021-08-13T12:08:53","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=7922"},"modified":"2022-04-13T16:30:45","modified_gmt":"2022-04-13T16:30:45","slug":"how-to-use-form-handling-in-javascript","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/","title":{"rendered":"How to use Form Handling in javascript"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Form Handling<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScript provides access to the forms within an HTML document through the Form object known as HTMLFormElement in the DOM. Which is a child of the Document Object.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Properties<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Properties<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Value<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">accept-charset<\/td><td class=\"has-text-align-center\" data-align=\"center\">UTF-8<\/td><td>Specifies the charset used in the submitted form (default: the page charset).<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">action<\/td><td class=\"has-text-align-center\" data-align=\"center\">URL<\/td><td>Contains a URL that defines where to send the data after submitting the form<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">autocomplete<\/td><td class=\"has-text-align-center\" data-align=\"center\">On (default)<br>Off<\/td><td>Determines that the browser retains the history of previous values.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">enctype<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><td>specifies how the browser encodes the data before it sends it to the server. (default: is url-encoded).<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">encoding<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><td>Holds the value of the enctype attribute, which usually contains either application\/x-www-form-urlencoded value or the multipart\/form-data value (in the case of file upload)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">elements[ ]<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><td>An array of DOM elements that correspond to the interactive form fields within the form<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Properties<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Properties<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Value<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">length<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><td>The number of a form field with a given form tag. Should bt the same as elements.length<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">method<\/td><td class=\"has-text-align-center\" data-align=\"center\">GET (default)<br>POST<\/td><td>Specifies how to send the form data to a web server. The data can be sent as URL variables, by using the get method or as HTTP post, by using the post method<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">name<\/td><td class=\"has-text-align-center\" data-align=\"center\">name<\/td><td>Specifies a name used to identify the form<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">novalidate<\/td><td class=\"has-text-align-center\" data-align=\"center\">novalidate<\/td><td>Specifies that the browser should not validate the form.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">target<\/td><td class=\"has-text-align-center\" data-align=\"center\">_self (default)<br>_blank<br>_parent<br>_top<br>framename<\/td><td>Specifies the target of the address in the action attribute<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Methods<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Method<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">checkValidity ( )<\/td><td>Returns a true or false value indicating whether or not all the fields in the form are in a valid state.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">reset ( )<\/td><td>Returns all form fields to their initial state.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">submit ( )<\/td><td>Submits the form to the URL specified in the form\u2019s action attribute<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Events: &#8211;<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>onreset<\/li><li>onsubmit<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Form Handling JavaScript provides access to the forms within an HTML document through the Form object known as HTMLFormElement in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16],"tags":[5999,6213,5725,6295,4459,5095,4240,1073],"class_list":["post-7922","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-document-object","tag-dom","tag-events","tag-form-handling","tag-html","tag-javascript","tag-method","tag-properties"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use Form Handling in javascript - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use Form Handling in javascript - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Form Handling JavaScript provides access to the forms within an HTML document through the Form object known as HTMLFormElement in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-13T12:08:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-13T16:30:45+00:00\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"How to use Form Handling in javascript\",\"datePublished\":\"2021-08-13T12:08:53+00:00\",\"dateModified\":\"2022-04-13T16:30:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/\"},\"wordCount\":294,\"commentCount\":0,\"keywords\":[\"document object\",\"DOM\",\"events\",\"Form Handling\",\"HTML\",\"Javascript\",\"Method\",\"properties\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/\",\"name\":\"How to use Form Handling in javascript - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-08-13T12:08:53+00:00\",\"dateModified\":\"2022-04-13T16:30:45+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-form-handling-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use Form Handling in javascript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use Form Handling in javascript - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"How to use Form Handling in javascript - scmGalaxy","og_description":"Form Handling JavaScript provides access to the forms within an HTML document through the Form object known as HTMLFormElement in [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/","og_site_name":"scmGalaxy","article_published_time":"2021-08-13T12:08:53+00:00","article_modified_time":"2022-04-13T16:30:45+00:00","author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"How to use Form Handling in javascript","datePublished":"2021-08-13T12:08:53+00:00","dateModified":"2022-04-13T16:30:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/"},"wordCount":294,"commentCount":0,"keywords":["document object","DOM","events","Form Handling","HTML","Javascript","Method","properties"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/","name":"How to use Form Handling in javascript - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-08-13T12:08:53+00:00","dateModified":"2022-04-13T16:30:45+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-form-handling-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to use Form Handling in javascript"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=7922"}],"version-history":[{"count":2,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7922\/revisions"}],"predecessor-version":[{"id":7926,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7922\/revisions\/7926"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=7922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=7922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=7922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}