+ Start a Discussion
Priya MishraPriya Mishra 

need a specific pattern to display in the field

I Have field call EIN(number type) it has to accept the 12-1234567  formate only means beginning 2 digit dash seven digit only. 

how to write the logic in apex to show the error on the vf page itself please help me out.

thanks in advance.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Priya,

There is a help article that has an implementation of using regex for validation, below is the one that I could build up, can you please try it once:


Help article: https://help.salesforce.com/articleView?id=000334073&type=1&mode=1

This article has an implementation of using the above regex in apex:


Let me know in case if there are any issues and in case if this comes in handy can you please choose this as the best answer so that it can be useful for others in the future.

David Jordan 25David Jordan 25
Joint torment is likely the most upsetting sensation you can actually feel. It's a dull and consistent inclination that you can't rapidly shake off. The most noticeably terrible part is, you feel it the most around evening time when you have an awkward sleeping pad.You must check best mattress for arthritis in lower back (https://www.readtopten.com/2020/09/best-rated-mattresses-for-arthritis-sufferers.html).
ANUTEJANUTEJ (Salesforce Developers) 
Priya in case if the above response came in handy can you please mark it as best answer so that it can be useful for others in the future.