How can a commandButton ignore validation for one particular required field?

I am working on a seemingly simple portal account page with the following markup:

<apex:page standardController="Contact" extensions="MyController">


                <apex:commandButton action="{!save}" value="Update"/>

            <apex:pageBlockSection title="Details" columns="2" id="details">
                <apex:inputField value="{!Contact.LastName}" label="Contact Name" required="true"/>
                <apex:commandButton action="{!updateContact}" value="Update Contact" rerender="details"/>
                <apex:inputField value="{!Contact.Account.Name}" label="Account Name" required="true"/>
                <apex:commandButton action="{!updateAccount}" value="Update Account" rerender="details"/>



When "Update Contact" is clicked I want the server to only validate the first field. Conversely the "Update Account" button should only validate the second field. When the main "Update" button is clicked I want the entire page to be validated.

I am seeing 2 solutions in front of me but I guess I'm not sure how to utilize them properly:

  • actionRegions
  • multiple forms

The pageBlockButtons wants to be the direct child of the pageBlock. Therefore I cannot wrap it inside a form. Also if I wrap the buttons inside actionRegions that will bypass validation.

  • do you use Contact.Account.Name as example contact field, or you want to update account itself? May 1, 2016 at 4:51
  • @IlyaLepesh I am updating the Account itself.
    – Mossi
    May 1, 2016 at 4:53
  • Could you please describe what kind of validation do you need? Only page validation, that field was provided? Or you talking about validation rules, each for object? May 1, 2016 at 5:30
  • @IlyaLepesh page validation
    – Mossi
    May 1, 2016 at 5:34

2 Answers 2


I believe wrapping the field-button pairs in actionRegions does the job! That way each button validates its counterpart field. Finally the main page-level button can be left alone to operate normally.


I think there will be no problem when you use validation code in controller. Both Command button call different methods. In updateContact() method, write validation of contact and in method updateAccount() write validation of account.

Hope it may helps you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .