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
vikrant kumarvikrant kumar 

Make atleast one checkbox select on row of pageblocktable

I have records with 3 checkboxes on pageblocktable.I have to select atleast one checkbox before saving on each record or should show an alert that one checkbox should be selected.Any help?
 
Rupal KumarRupal Kumar

Hi vikrant,
       See below link-
     http://lab.artlung.com/validate-checkbox/
     http://salesforce.stackexchange.com/questions/99309/create-a-popup-window-giving-a-message-as-select-a-row  (http://salesforce.stackexchange.com/questions/99309/create-a-popup-window-giving-a-message-as-select-a-row)
      https://developer.salesforce.com/forums/?id=906F000000093KYIAY


Thanks

Rupal Kumar
Mirketa Software Pvt Ltd
http://mirketa.com/index.html

 
Rupal KumarRupal Kumar

Hi vikrant,
Try this code=
<apex:page>
<apex:form id= "theForm">
<script type="text/javascript" language="JavaScript">



function chekcboxscript(){
    var checkbox1 = document.getElementById("check1").checked;
    
    var checkbox2 = document.getElementById("check2").checked;
    var checkbox3 = document.getElementById("check3").checked;
    if(checkbox1 == false && checkbox2 == false && checkbox3 == false){
        alert('Please check atleast one checkbox.');
    }
    
}

</script> 

    <p><input type="CHECKBOX" name="CHECKBOX_1" value="This..." id="check1"/> This...</p>
    <p><input type="CHECKBOX" name="CHECKBOX_2" value="That..." id="check2"/> That...</p>
    <p><input type="CHECKBOX" name="CHECKBOX_3" value="...and The Other" id="check3"/> ...and The Other</p>
    <p><input type="button" value="Submit!" onclick="chekcboxscript();"/></p>

</apex:form>
</apex:page>


Thanks

Rupal Kumar
Mirketa Software Pvt Ltd
http://mirketa.com/index.html
vikrant kumarvikrant kumar
This works for normal fields but i want for checkboxes in a row  in pageblocktable.atleast one checkbox in a row  should be selected.