+ Start a Discussion
S SaiS Sai 

validation error in visualforce

HI all,

When i am not filling  any <apex:inputTex> text field then i Want to display validation error using apex visualforce page
Like below  

User-added image
Sandy GaliSandy Gali
In the <apex:inputText> make the required attribute true and use <apex:pagemessages>

Sample code :

<apex:page standardController="Account">
         Name: <apex:inputText id="field1" value="{!Account.Name}" required="true"/>
             <apex:commandButton value="Save" action="{!save}"/>