You need to sign in to do that
Don't have an account?
Problem in required="true"
Hi..
In my VF page Name field is set required=true. When Name filed is blank I hit the cancel button It shows the validation error message 'Error: You must enter a value'.
How to avoid it...
My sample code
Page:
<apex:page controller="RequiredTest">
<apex:form >
<apex:pageblock>
<apex:outputlabel value="Name"/>
<apex:inputfield value="{!cus.Name}" required="true"/>
<apex:outputlabel value="Number"/>
<apex:inputfield value="{!cus.No__c}" />
<apex:commandbutton value="Cancel" action="{!cancel}"/>
</apex:pageblock>
</apex:form>
</apex:page>
Controller:
public class RequiredTest
{
Custom__c cus;
public Custom__c getcus()
{
return cus;
}
public pagereference cancel()
{
pagereference can=new pagereference ('500/o'); // Here 500 is my custom object tab url
can.setRedirect(true);
return can;
}
}
This is my 100th post
All Answers
Thanks Jim..
Its work fine.
I need one additional info from u.
When I use required="true" for Number field without immediate="true" its also working fine.
Why its working...?
<apex:inputfield value="{!cus.No__c}" required="true" />
I don't know the answer to that. I have experienced similar inconsistancies.
My solution, using the immediate, seems to take care of it, so I have just used that.
Thanks Jim.
Your solution is very helpful for me...