I have an with required="TRUE". For some reason it isn't getting throwing error even if I save it without checking the box.

Here's the VF Code.

    <apex:outputPanel styleClass="margin-t3" layout="block" >
        <div class="row">           
            <div class="form-group no-margin">                                                                                                        
                 <apex:inputCheckbox required="TRUE" value="{!app.Reviewed__c}" id="Reviewed"/>
                 <label> I verify that I have reviewed this. </label>                                 
        </div><!--  end row -->

<apex:commandlink styleClass="btn btn-primary btn-lg" action="{!navigator}" id="nextlink" onComplete="rerunjs();" reRender="webform" status="onsubmit">
    <apex:commandButton value="Save & Continue" id="continuebutton" />

In the class though, I just update app. No errors and the page redirects to the next page.

I want to make the checkbox mandatory in the VF page itself. I don't want to touch apex for this. Please let me know what is wrong here.

  • Are you using immediate="true" somewhere on the command button for example? Mar 20 '15 at 8:48
  • Nope, im not using. I will update the command button code also here.
    – sfdcFanBoy
    Mar 20 '15 at 8:51
  • 1
    On the other hand how do you want to make the checkbox mandatory? Should it be implicitly checked? If a checkbox is not checked it will get a value nevertheless (false). From my point of view it is not necessary to make a checkbox mandatory. It will get a value in any case. Checked -> TRUE, not checked -> FALSE. Mar 20 '15 at 8:56
  • This is like Read Terms & Conditions checkbox. Must be checked by everyone. I used Reruired="true"
    – sfdcFanBoy
    Mar 20 '15 at 9:12
  • 1
    You should do the check in controller. Mar 20 '15 at 9:33

The required attribute doesn't work in the checkbox the way you expect. Since false (unchecked) is a valid answer, the form can submit. What you need to do is add a validation in your save code that tests the checkbox and either saves or pushes a page message to the user about the requirement to check the box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.