You need to sign in to do that
Don't have an account?

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:
try{ upsert contact; } catch (Exception e){ ApexPages.addMessages(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:
http://bobbuzzard.blogspot.com/2011/04/field-level-error-messages-with.html
and
http://bobbuzzard.blogspot.com/2011/04/field-level-error-messages-with_29.html
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.
Thanks
Sreenath
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.