function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Siddhant kandeSiddhant kande 

Checkbox validation using javascript on Visualforce Page

Hello All,
I have following vf code which populates the checkbox on browser as given below.
VF Code:
      <Apex:pageBlockSection title="Products" columns="1" id="pbsec55" >
            <apex:selectCheckboxes id="products" value="{!product}">
                <apex:selectOptions value="{!productOption}" id="items"></apex:selectOptions>
        </apex:selectCheckboxes>        
        </Apex:pageblockSection>         

Browser 
User-added image

QA:
I want that before this form is submitted at least on check box must be checked. Would like to do checkbox validation using javascript.
Also, what are different ways I can to do checkbox validation on visualforce page?
 
Sumitkumar_ShingaviSumitkumar_Shingavi
It is pretty easy. Don't use JS for this. When you say "before this form is submitted" means you must be having a button so just add a validation in the beginning of your Submit method check on if(product != null) and you need to intialize product = null in constructor for this validation. Hope this helps!
Michael Alamag 2Michael Alamag 2
I got same issue. Is anyone here already encountered this and solved it?