• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF validation

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to validate a field for a regex and am using the code as shown below



When I enter an invalid name, the message I get back is "Regex Pattern not matched". How do I get a custom message shown on the UI like "Name cannot contain invalid characters"
Should I write a custom validator?

Thanks in advance
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a validatorMessage attribute to the inputText control. You have to have JSF 1.1 or higher, I think, and I may not have spelled the attribute name correctly, so it's best to check the JSF tag docs, but I do this all the time (also custom requiredMessage's).
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks TIm, it worked
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!