JSFiddle - React, Tailwind, and code Playground

by vinodlouis

HTML

<form name="frm" method="post" action="#" onsubmit="return ValidateSchool(this)">
  <div class="TopAlphaWrapper">
    <div id="topMainAlpha">
      <div id="TopAlphaOneLeft">
        <div class="email_alert_checkbx_list filter-div ln-a" data-filter="Admiralty Primary School" style="display: block;">
          <label id="lbl_type0" class="label_check c_off" name="school" style="width:230px !important;">
            <input name="school[]" class="chkBX" value="1.442917,103.799744" type="checkbox">
            Admiralty Primary School</label>
        </div>
        <div class="email_alert_checkbx_list filter-div ln-a" data-filter="Admiralty Secondary School" style="display: block;">
          <label id="lbl_type1" class="label_check c_off" name="school" style="width:230px !important;">
            <input name="school[]" class="chkBX" value="1.446367,103.801608" type="checkbox">
            Admiralty Secondary School</label>
        </div>
        <div class="email_alert_checkbx_list filter-div ln-a" data-filter="Advent Learning" style="display: block;">
          <label id="lbl_type2" class="label_check c_off" name="school" style="width:230px !important;">
            <input name="school[]" class="chkBX" value="1.324952,103.851188" type="checkbox">
            Advent Learning</label>
        </div>
        <div class="email_alert_checkbx_list filter-div ln-a" data-filter="AEC Business School" style="display: block;">
          <label id="lbl_type3" class="label_check c_off" name="school" style="width:230px !important;">
            <input name="school[]" class="chkBX" value="1.282717,103.818904" type="checkbox">
            AEC Business School</label>
        </div>
        <div class="email_alert_checkbx_list filter-div ln-a" data-filter="Ahmad Ibrahim Primary School " style="display: block;">
          <label id="lbl_type4" class="label_check c_off" name="school" style="width:230px !important;">
            <input name="school[]" class="chkBX"...

JavaScript

function ValidateSchool(form){
    var cat_school = document.getElementsByName('school[]');  
    var j=0;

    for (i = 0; i < cat_school.length; i++){
        
        if (cat_school[i].checked){
            j++;
        }
    }
    if(j>0){
        alert("item selected");
        return true;
    }
    else{
        alert("select atleast one value");
        return false;
    }
}