{"id":1389,"date":"2023-06-08T09:57:55","date_gmt":"2023-06-08T08:57:55","guid":{"rendered":"https:\/\/codeflarelimited.com\/blog\/?p=1389"},"modified":"2023-06-08T09:58:44","modified_gmt":"2023-06-08T08:58:44","slug":"validate-checkbox-in-react-js","status":"publish","type":"post","link":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/","title":{"rendered":"Validate Checkbox in React JS"},"content":{"rendered":"\n<p>In web development, a checkbox is a user interface element that allows users to select one or multiple options from a predefined set of choices. It is typically represented by a small square box that can be checked or unchecked.<\/p>\n\n\n\n<p>In this tutorial, we validate checkbox in React and create corresponding functions to handle that.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-does-a-checkbox-work\">How Does a Checkbox Work?<\/h2>\n\n\n\n<p>The checkbox element in HTML is created using the <code>&lt;input&gt;<\/code> tag with the <code>type<\/code> attribute set to &#8220;checkbox&#8221;. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"markup\" class=\"language-markup\">&lt;input type=\"checkbox\" name=\"option1\" value=\"Option 1\"&gt; Option 1&lt;br&gt;\n&lt;input type=\"checkbox\" name=\"option2\" value=\"Option 2\"&gt; Option 2&lt;br&gt;\n&lt;input type=\"checkbox\" name=\"option3\" value=\"Option 3\"&gt; Option 3&lt;br&gt;\n<\/code><\/pre>\n\n\n\n<p>In the example above, we have three checkboxes labeled &#8220;Option 1,&#8221; &#8220;Option 2,&#8221; and &#8220;Option 3.&#8221; Each checkbox has a unique <code>name<\/code> and <code>value<\/code> attribute. When the form containing these checkboxes is submitted, the selected checkboxes&#8217; values are sent to the server for processing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-does-a-checkbox-work-in-vanilla-javascript\">How Does a Checkbox Work in Vanilla JavaScript?<\/h2>\n\n\n\n<p>In web development, you can use JavaScript to handle checkbox interactions and retrieve their state. Each checkbox has a <code>checked<\/code> property that you can access using JavaScript to determine if it is currently selected or not. You can attach event listeners to checkboxes to respond to user interactions, such as when a checkbox is clicked or its state changes.<\/p>\n\n\n\n<p>Here&#8217;s an example of how you can use JavaScript to handle checkbox interactions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">&lt;input type=\"checkbox\" id=\"myCheckbox\"&gt; Check me!\n\n&lt;script&gt;\n  const checkbox = document.getElementById('myCheckbox');\n  \n  checkbox.addEventListener('change', function() {\n    if (checkbox.checked) {\n      console.log('Checkbox is checked!');\n    } else {\n      console.log('Checkbox is unchecked!');\n    }\n  });\n&lt;\/script&gt;\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-validate-checkbox-in-react\">Validate Checkbox in React<\/h2>\n\n\n\n<p>In React, you can use the <code>input<\/code> element with the <code>type<\/code> attribute set to &#8220;checkbox&#8221; to create a checkbox. Here&#8217;s an example of how to use checkboxes in a React component:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">  &lt;div className=\"container d-flex justify-content-center\"&gt;\n        &lt;div className=\"col-md-4\"&gt;\n          &lt;div className=\"input-group input-group-outline mb-3\"&gt;\n            &lt;input type=\"checkbox\" className=\"col-sm-4\" onChange={this.handleUpdate}\/&gt;Can update\n            &lt;input type=\"checkbox\" className=\"col-sm-4\" onChange={this.handleApprove}\/&gt;Can approve\n            &lt;input type=\"checkbox\" className=\"col-sm-4\" onChange={this.handleDelete}\/&gt;Can delete\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;<\/code><\/pre>\n\n\n\n<p>Now, we can&#8217;t just handle this the way traditional JavaScript does by assigning it an <strong><em>id<\/em><\/strong> and then getting its value. We have to take a different approach.<\/p>\n\n\n\n<p>We will create 3 functions that will handle the checkbox input as follows. But first, we have to create state variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">constructor(props){\n    super(props);\n    this.state = {\n      update: \"\",\n      approve: \"\",\n      delete: \"\"\n    }\n  }<\/code><\/pre>\n\n\n\n<p>These 3 state variables will be set when their respective checkboxes are clicked.<\/p>\n\n\n\n<p>Next, we have to create 3 functions that will update the state variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">handleUpdate(e) {\n    this.setState({ update: e.target.checked });\n  }\n  \n  handleApprove(e) {\n    this.setState({ approve: e.target.checked });\n  }\n  \n  handleDelete(e) {\n    this.setState({ delete: e.target.checked });\n  }<\/code><\/pre>\n\n\n\n<p>Next, we bind these functions to the state.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">constructor(props){\n    super(props);\n    this.state = {\n      update: \"\",\n      approve: \"\",\n      delete: \"\"\n    }\n    this.handleUpdate = this.handleUpdate.bind(this);\n    this.handleApprove = this.handleApprove.bind(this);\n    this.handleDelete = this.handleDelete.bind(this);\n  }<\/code><\/pre>\n\n\n\n<p>We can quickly check if the function is returning any value as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">  handleUpdate(e) {\n    this.setState({ update: e.target.checked }, ()=&gt; {\n      alert(this.state.update)\n    });\n  }<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"317\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.32.32-AM-1024x317.png\" alt=\"validate react checkbox\" class=\"wp-image-1392\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.32.32-AM-1024x317.png 1024w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.32.32-AM-300x93.png 300w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.32.32-AM-768x238.png 768w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.32.32-AM.png 1308w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, we write a function that will check if the box is checked or not.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">  validateUser = () =&gt; {\n    const { update, approve, delete_privilege } = this.state;\n    if(approve === \"\"){\n    alert(\"specify approve privilege\")\n  }else if(update === \"\"){\n      alert(\"specify update privilege\")\n    }else if(delete_privilege === \"\"){\n      alert(\"specify delete privilege\")\n    }\n  }<\/code><\/pre>\n\n\n\n<p>Here&#8217;s the result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"251\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.38.17-AM-1024x251.png\" alt=\"checkbox validation in react\" class=\"wp-image-1393\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.38.17-AM-1024x251.png 1024w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.38.17-AM-300x73.png 300w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.38.17-AM-768x188.png 768w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Screen-Shot-2023-06-08-at-1.38.17-AM.png 1295w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This is how we validate checkbox in React<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-here-s-the-full-code\">Here&#8217;s the full code<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">import React, { Component } from 'react';\n\n\nclass App extends Component {\n\n  constructor(props){\n    super(props);\n    this.state = {\n      update: \"\",\n      approve: \"\",\n      delete_privilege: \"\"\n    }\n    this.handleUpdate = this.handleUpdate.bind(this);\n    this.handleApprove = this.handleApprove.bind(this);\n    this.handleDelete = this.handleDelete.bind(this);\n  }\n\n  validateUser = () =&gt; {\n    const { update, approve, delete_privilege } = this.state;\n    if(approve === \"\"){\n    alert(\"specify approve privilege\")\n  }else if(update === \"\"){\n      alert(\"specify update privilege\")\n    }else if(delete_privilege === \"\"){\n      alert(\"specify delete privilege\")\n    }\n  }\n\n  handleUpdate(e) {\n    this.setState({ update: e.target.checked }, ()=&gt; {\n      alert(this.state.update)\n    });\n  }\n\n  handleApprove(e) {\n    this.setState({ approve: e.target.checked });\n  }\n\n  handleDelete(e) {\n    this.setState({ delete: e.target.checked });\n  }\n\n  render(){\n    return(\n      &lt;div className=\"container d-flex justify-content-center\" &gt;&lt;br \/&gt;\n      &lt;div className=\"card-body\"&gt;\n      &lt;ul className=\"list-group\"&gt;\n     &lt;li className=\"list-group-item border-0 p-4 mb-2 bg-gray-100 border-radius-lg\"&gt;\n      &lt;h6 className=\"mb-3 text-sm\"&gt;Assign Privileges&lt;\/h6&gt;\n      &lt;div className=\"row\"&gt;\n        &lt;div className=\"col-md-4\"&gt;\n          &lt;div className=\"d-flex justify-content-center\"&gt;\n            &lt;input type=\"checkbox\" className=\"col-sm-2\" onChange={this.handleApprove}\/&gt;\n             Can approve\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n\n        &lt;div className=\"col-md-4\"&gt;\n          &lt;div className=\"d-flex justify-content-center\"&gt;\n            &lt;input type=\"checkbox\" className=\"col-sm-2\" onChange={this.handleUpdate}\/&gt;\n             Can update\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n\n        &lt;div className=\"col-md-4\"&gt;\n          &lt;div className=\"d-flex justify-content-center\"&gt;\n            &lt;input type=\"checkbox\" className=\"col-sm-2\" onChange={this.handleDelete}\/&gt;\n             Can delete\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n\n      &lt;\/div&gt;\n    &lt;\/li&gt;\n  &lt;\/ul&gt;\n  &lt;div className=\"text-end mt-4\"&gt;\n    &lt;button  onClick={() =&gt; this.validateUser()} className=\"btn btn-success btn-lg mb-0\"&gt;\n    SUBMIT\n    &lt;\/button&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;\n&lt;\/div&gt;\n    )\n  }\n}\n\nexport default App;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>Overall, checkboxes are useful for allowing users to select one or multiple options from a list and are commonly used in forms, preference settings, and other interactive web components.<\/p>\n\n\n\n<p><a href=\"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/\" target=\"_blank\" rel=\"noreferrer noopener\">Conditional Rendering in React<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In web development, a checkbox is a user interface element that allows users to select one or multiple<\/p>\n","protected":false},"author":1,"featured_media":1394,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[98],"tags":[],"class_list":["post-1389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-softare-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Validate Checkbox in React JS<\/title>\n<meta name=\"description\" content=\"in this tutorial we will validate checkbox in React. Checkbox is a user interface element that allows users to select one or multiple options\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Validate Checkbox in React JS\" \/>\n<meta property=\"og:description\" content=\"in this tutorial we will validate checkbox in React. Checkbox is a user interface element that allows users to select one or multiple options\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/codeflretech\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-08T08:57:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-08T08:58:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"codeflare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeflaretech\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/\"},\"author\":{\"name\":\"codeflare\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\"},\"headline\":\"Validate Checkbox in React JS\",\"datePublished\":\"2023-06-08T08:57:55+00:00\",\"dateModified\":\"2023-06-08T08:58:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/\"},\"wordCount\":392,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Untitled-Design-5.jpeg\",\"articleSection\":[\"softare development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/\",\"name\":\"Validate Checkbox in React JS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Untitled-Design-5.jpeg\",\"datePublished\":\"2023-06-08T08:57:55+00:00\",\"dateModified\":\"2023-06-08T08:58:44+00:00\",\"description\":\"in this tutorial we will validate checkbox in React. Checkbox is a user interface element that allows users to select one or multiple options\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#primaryimage\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Untitled-Design-5.jpeg\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Untitled-Design-5.jpeg\",\"width\":1200,\"height\":628,\"caption\":\"validate checkbox in React\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/validate-checkbox-in-react-js\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"softare development\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/softare-development\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Validate Checkbox in React JS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"name\":\"\",\"description\":\"Sustainable solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\",\"name\":\"Codeflare Limited\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"width\":1040,\"height\":263,\"caption\":\"Codeflare Limited\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\",\"name\":\"codeflare\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"caption\":\"codeflare\"},\"description\":\"Latest tech news and coding tips.\",\"sameAs\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\",\"https:\\\/\\\/facebook.com\\\/codeflretech\",\"https:\\\/\\\/instagram.com\\\/codeflaretech\",\"https:\\\/\\\/x.com\\\/codeflaretech\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1\"],\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/author\\\/watcher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Validate Checkbox in React JS","description":"in this tutorial we will validate checkbox in React. Checkbox is a user interface element that allows users to select one or multiple options","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:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/","og_locale":"en_US","og_type":"article","og_title":"Validate Checkbox in React JS","og_description":"in this tutorial we will validate checkbox in React. Checkbox is a user interface element that allows users to select one or multiple options","og_url":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/","article_author":"https:\/\/facebook.com\/codeflretech","article_published_time":"2023-06-08T08:57:55+00:00","article_modified_time":"2023-06-08T08:58:44+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg","type":"image\/jpeg"}],"author":"codeflare","twitter_card":"summary_large_image","twitter_creator":"@codeflaretech","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#article","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/"},"author":{"name":"codeflare","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a"},"headline":"Validate Checkbox in React JS","datePublished":"2023-06-08T08:57:55+00:00","dateModified":"2023-06-08T08:58:44+00:00","mainEntityOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/"},"wordCount":392,"commentCount":0,"publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg","articleSection":["softare development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/","url":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/","name":"Validate Checkbox in React JS","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#primaryimage"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg","datePublished":"2023-06-08T08:57:55+00:00","dateModified":"2023-06-08T08:58:44+00:00","description":"in this tutorial we will validate checkbox in React. Checkbox is a user interface element that allows users to select one or multiple options","breadcrumb":{"@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#primaryimage","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg","width":1200,"height":628,"caption":"validate checkbox in React"},{"@type":"BreadcrumbList","@id":"https:\/\/codeflarelimited.com\/blog\/validate-checkbox-in-react-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeflarelimited.com\/blog\/"},{"@type":"ListItem","position":2,"name":"softare development","item":"https:\/\/codeflarelimited.com\/blog\/softare-development\/"},{"@type":"ListItem","position":3,"name":"Validate Checkbox in React JS"}]},{"@type":"WebSite","@id":"https:\/\/codeflarelimited.com\/blog\/#website","url":"https:\/\/codeflarelimited.com\/blog\/","name":"","description":"Sustainable solutions","publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeflarelimited.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codeflarelimited.com\/blog\/#organization","name":"Codeflare Limited","url":"https:\/\/codeflarelimited.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","width":1040,"height":263,"caption":"Codeflare Limited"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a","name":"codeflare","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","caption":"codeflare"},"description":"Latest tech news and coding tips.","sameAs":["https:\/\/codeflarelimited.com\/blog","https:\/\/facebook.com\/codeflretech","https:\/\/instagram.com\/codeflaretech","https:\/\/x.com\/codeflaretech","https:\/\/www.youtube.com\/channel\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1"],"url":"https:\/\/codeflarelimited.com\/blog\/author\/watcher\/"}]}},"jetpack_featured_media_url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/06\/Untitled-Design-5.jpeg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/comments?post=1389"}],"version-history":[{"count":3,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1389\/revisions"}],"predecessor-version":[{"id":1396,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1389\/revisions\/1396"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media\/1394"}],"wp:attachment":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media?parent=1389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/categories?post=1389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/tags?post=1389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}