You need to sign in to do that
Don't have an account?

Immediate="true" is not stopping required field validation on VF Page
Here is a simplified version of my page:
What am I missing here?
<apex:page standardcontroller="Case" extensions="TestPassJSVariable"> <script type="text/javascript"> function createCase(cancel) { var supplier = document.getElementById('{!$Component.form.block.section1.supplierInput}').value; if(cancel == 1) { cancelFunction(); } else { createFunction(supplier); } </script> <apex:form id="form"> <apex:actionFunction name="createFunction" action="{!createCase}" rerender="view"> <apex:param id="supplier" assignTo="{!supplier}" name="supplier" value="" /> </apex:actionFunction> <apex:actionFunction name="cancelFunction" action="{!cancelCreate}"/> <apex:inputField id="supplierInput" value="{!Case.Supplier__c}" required="true"/> <apex:commandButton value="Create" onclick="createCase();" rerender="view"/><apex:commandButton value="Cancel" onclick="createCase(1);" immediate="true"/></center> </apex:form> </apex:page>I am trying to make the "supplierInput" field required, but also allow a cancel button on the page to go back to the previous URL without having to enter that information in. I thought the immediate="true" attribute was supposed to allow this to happen, but it isn't working.
What am I missing here?
//Javascript function
function createCase(cancel) {
////////////////
Exsiting Code
//////////////////////////////
return false;
}
put immediate="true" attribute on your action functions.
<apex:commandButton value="Create" onclick="return createCase();" rerender="view"/>
<apex:commandButton value="Cancel" onclick="return createCase(1);" />
All Answers
I added immediate="true" to the apex:actionFunction and still required all fields when I click the cancel button.
Still something wrong with the code?
//Javascript function
function createCase(cancel) {
////////////////
Exsiting Code
//////////////////////////////
return false;
}
put immediate="true" attribute on your action functions.
<apex:commandButton value="Create" onclick="return createCase();" rerender="view"/>
<apex:commandButton value="Cancel" onclick="return createCase(1);" />
However, now another issue has arisen. When I click on the Create button withOUT all the required fields filled in no warning (validation) messages show on the screen. It doesn't proceed in creating the case, which is good. But, the little red messages no longer appear under the corresponding fields either. Here is the code I have now:
I tried adding immediate="true" to the createFunction as well but that didn't change anything.
Thoughts?
and probably can add a page message <apex:pageMessages/>
Thanks to you both!!