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
mac adminmac admin 

Check box filed as mandetory in custom vfpage

Hi all,
I want to make the check box as mandetory before saving my custom vfpage. Can anyone help me over here.
Is standard validation work here..?

Rowallim TechnologyRowallim Technology
Hii mac admin
You should use this(required="true") in your vfpage.
Hope it will help you.
Mark it as best answer if you got your answer.
mac adminmac admin
Hi Rowallim Technology,
I have already tried it but i didn't get any result .
brahmaji tammanabrahmaji tammana
Hi mac,

You can try using Javascript validation to achieve this.
Please try with document.getElementById(XXXXX).value (something like this) to get the value of checkbox and use it before saving the record.

Hope it works. I will also try give an example.

Thank you 
brahmaji tammanabrahmaji tammana
Hi mac,

Here is the sample code which can make the checkbox mandatory.

I just used javascript validation to achieve this. I am not sure any other solution to achieve this.
<apex:page Controller="MyAccount">
        function saverecord()
                alert('Dude, Select the checkbox');
<apex:form id='fm'>
    <apex:pageBlock id="pb">
        <apex:pageBlockSection id="pbs">
            <apex:inputField value="{!}" id="ac"/>
            <apex:inputCheckbox id="cb" ></apex:inputCheckbox>            
            <apex:commandButton value="Save" onclick="saverecord()" />
    <apex:actionFunction action="{!WriteyourOwnMethod}"  name="saveit"  />