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

Display errormessage next to field

On my VF page, when I leave a must-field empty, it nicely displays the error message next to the field which throws that error.


I have a few fields which have a validation rule defined. If the validationrule fails, it does not show the error next to my VF input field.


This is how I treat my errors:


In the controller:


    upsert contact;
} catch (Exception e){

 At the moment, this error can only be displayed when I use a <apex:pageMessages /> tag.


But I really need to display the error messages at field level.




When you create a validation rule you have the option of displaying the error message at the top of the page or next to your field.  If you have your rule set up to display next to your field (and that field is on your page) it should display where you want it to.


There's a few other ways that you could achieve this if the validation rule isn't displaying the error against the field.


I've written a couple of blog posts explaining the options at:




Hi Bob,


               I need help in the same issue of input text need to display error messages. I have written a simple validation rule for first name field to enter only letters, I am trying to check my condition in the loop of snippet in your blog using some symbols. I am unable to get. please provide any suggestions to make it validate to enter only letters.






You'd usually do that via the Pattern and Matcher functionality - that would allow you to compare the input to a regular expression.


Hi Bob,


                Thanks for the way to find my solution.