{"id":588,"date":"2024-01-19T11:33:03","date_gmt":"2024-01-19T17:33:03","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=588"},"modified":"2024-01-19T11:33:03","modified_gmt":"2024-01-19T17:33:03","slug":"progressively-enhanced-form-validation","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/progressively-enhanced-form-validation\/","title":{"rendered":"Progressively Enhanced Form Validation"},"content":{"rendered":"\n<p>Here&#8217;s a thing you&#8217;re sure to do in your web developer career: add form validation to a form. You can&#8217;t leave that name field blank! That doesn&#8217;t look like an email address! That quantity is too high! Forms are a part of the beating heart of the web, and especially important to <em>business<\/em>. You can&#8217;t charge a credit card with an invalid card number, and you can&#8217;t let someone order 5 rice cookers if you only have 4 in stock. <\/p>\n\n\n\n<p>These days, the approach to form validation should be:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start with semantic, valid, accessible HTML. You can do some level of validation on forms right in HTML. <\/li>\n\n\n\n<li>Layer on CSS, adjusting the styles for form elements in different states of validity. <\/li>\n\n\n\n<li>Layer on JavaScript, filling in gaps that HTML can&#8217;t do and making things <em>more<\/em> accessible.<\/li>\n<\/ol>\n\n\n\n<p>It&#8217;s a lot! But it&#8217;s worth doing right. Fortunately, <a href=\"https:\/\/cloudfour.com\/thinks\/progressively-enhanced-form-validation-part-1-html-and-css\/\">Gerardo Rodriguez&#8217;s 4-part series<\/a> and <a href=\"https:\/\/constraint-validation-api-demo.netlify.app\/part-4\/\">demo<\/a>\/<a href=\"https:\/\/github.com\/cloudfour\/constraint-validation-api-demo\">repo<\/a> is a very good reference. You might want to <a href=\"https:\/\/frontendmasters.com\/courses\/cypress\/form-validation\/?utm_source=boost&amp;utm_medium=blog&amp;utm_campaign=boost\" data-type=\"link\" data-id=\"https:\/\/frontendmasters.com\/courses\/cypress\/form-validation\/?utm_source=boost&amp;utm_medium=blog&amp;utm_campaign=boost\">test those forms<\/a>, too. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a thing you&#8217;re sure to do in your web developer career: add form validation to a form. You can&#8217;t leave that name field blank! That doesn&#8217;t look like an email address! That quantity is too high! Forms are a part of the beating heart of the web, and especially important to business. You can&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[7,82,31,3],"class_list":["post-588","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-css","tag-form-validation","tag-html","tag-javascript"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/01\/validation-thumb.jpg?fit=1000%2C500&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=588"}],"version-history":[{"count":2,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":591,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/588\/revisions\/591"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/590"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}