How to make Field as Required in Visualforce page?
Hi,
In this post i am giving a simple visualforce example of making a not-required field as required in Visualforce Page.
Visualforce Page:
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock >
<apex:pageblocksection title="Account Information">
<apex:inputfield value="{!account.Name}"/>
<!--
<apex:inputField value="{!account.AccountNumber}"/>
<apex:inputfield value="{!account.AccountNumber}" required="true"/>
</apex:pageblockSection>
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageblockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Output :
if you observe in the standard page layout the account-number is not required field on account object. i maed it as required in visualforce page with the
<apex:inputfield value="{!account.AccountNumber}" required="true"/> tag.
in Visualforce page if you try to save the record with out enter any value in Account Number field it is showing the error message
That's it ...
Thanks for reading........
0 comments:
Post a Comment