+ Start a Discussion
chenna1234chenna1234 

Displaying custom error message on vf page if field is not filled

Hi All, I kept required=" true" only vf page where it shows red mark on it. but i need to display custom error message on top of vf page if field is not filled.....

Best Answer chosen by Admin (Salesforce Developers) 
SFFSFF

Three things:

 

1. You need to use the <apex:pagemessages /> tag near the top of your page so that errors are displayed.

2. You probably don't want to use required="true" because the error message that is returned is not configurable. If you add your own custom save() method, you can return a good error message using these techniques:

 

http://www.salesforcefast.com/2011/06/make-easy-to-use.html

 

3. If you don't use the required="true" attribute, you can use this technique to set up the red bar to indicate a required field:

 

http://www.salesforcefast.com/2010/07/displaying-required-fields-in.html

All Answers

SFFSFF

Three things:

 

1. You need to use the <apex:pagemessages /> tag near the top of your page so that errors are displayed.

2. You probably don't want to use required="true" because the error message that is returned is not configurable. If you add your own custom save() method, you can return a good error message using these techniques:

 

http://www.salesforcefast.com/2011/06/make-easy-to-use.html

 

3. If you don't use the required="true" attribute, you can use this technique to set up the red bar to indicate a required field:

 

http://www.salesforcefast.com/2010/07/displaying-required-fields-in.html

This was selected as the best answer
nishad basha 7nishad basha 7
how to display  in user fields when  i enter click sumbit button the error message will be shown