+ 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
Thanks 
SS
Sandy GaliSandy Gali
In the <apex:inputText> make the required attribute true and use <apex:pagemessages>

Sample code :

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