function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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>