Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am creating a custom vf page without any standard controller. And i need to implement cancel button functionality. following is the code i am using:


<apex:commandbutton value="Cancel" action="{!gotoClientListPage}" immediate="true"/>


public PageReference gotoClientListPage()
    PageReference page = new PageReference('/apex/Setup_Client_List_Layout');
    return page;

But when i click on this button following error occurs: Image

Can anyone help me solve this error. Thnx in advance.

share|improve this question

Setting the immediate="true" attribute will bypass any Salesforce validation and view state updating. The fact that you are seeing fields marked as required suggests that there is some custom client side validation being carried out, through JavaScript for example (especially as the error message popout isn't standard Salesforce).

You can avoid the JavaScript validation by setting a JavaScript variable, e.g. cancelling=true, via an onclick handler for the button and then changing the custom validation to check if cancelling is set to true and if it is, skip the validation.

share|improve this answer
Actualy, this is salesforce standard error message. It appears if inputField is explicity marked required by setting required=true. But thanx for illuminating me that problem is on client side validation. :) – Shoaib Shakeel Feb 6 '14 at 9:25
I don't recall seeing the error message presented in a popout as it is in this case. Is this on a regular page? – Bob Buzzard Feb 6 '14 at 9:45
yes. i used following code to create inputField.<apex:inputField value="{!pastDealObject.Name}" required="true" /> – Shoaib Shakeel Feb 6 '14 at 9:54
I just see the message under the field. Weird. – Bob Buzzard Feb 6 '14 at 10:01

While applying cancel operation visualforce you should stop the form validation.Use below any one methods to stop the form validation based on your requirements.

Method 1:

Using html-5 in doctype in visualforce page means you should use html-formnovalidate and immediate in cancel button. For example

<apex:commandButton action="{!cancel}" value="Cancel" immediate="true" 
                    html-formnovalidate="formnovalidate" />

Method 2:

you should use immediate key word only need for stopping form validation. For Example

 <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
share|improve this answer
up vote 1 down vote accepted

This problem is being caused by browsers due to HTML 5 form validation. So i just added novalidate attribute to my form elements and it worked fine. For more information:

share|improve this answer

try this in case it is custom controller and not using standard cancel action the this:

 oncomplete="'/{!$CurrentPage.parameters.opportunityId}', '_parent');" 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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