Tuesday, March 28, 2017

How To Check Whether at Least One Check Box Checked or Not? Using JQuery

If you want to know whether at least one check box is checked or not in visual force it's very easy using Jquery .Please use the below code snippet to check this functionality.

Sample Source Code:


function selectionCheck(selClass)
   {
          
        var chbxClass = '.'+selClass; // selClass is styleclass name for all your checkbox
          
        if($(chbxClass).is(':checked'))
  {
   alert('You have selected one or more records');
  }
                
        else
        {
            alert('Please select at least one record');
            return false;
        }
  }


In the above code if you see we are one jQuery method called is() ,this method will loop through the all the list and returns true if at least one record has checked among the list otherwise it will return false.


Thanks for visiting..hope this helps you!



No comments: