return false is not working

前端 未结 2 683
旧时难觅i
旧时难觅i 2021-01-27 09:25

I have created one form with dynamically created check box\'s . And i have used one j query script that will check weather user has checked at-least one check box or not .Tf it

2条回答
  •  野性不改
    2021-01-27 09:53

    Try this code:

    Add class to check box

    print "\n";
    

    jQuery function:

    function Validate() {
      var counter=0;
    
      $( ".mycheckbox" ).each(function() {
        if($(this).is(':checked'))
        {
          counter++
        }
      });
    
      if (counter == 0)
      {
        alert("You have not selected an item to delete");
        return false;
      }
      else
      {
        alert("Are you sure you want to delete  "+counter+" records");
      }
    }
    

提交回复
热议问题