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
Manish Anand 10Manish Anand 10 

Validation on VF, input field.

Hi,

How we can implement below validation on VF input field?
Create an input component on VF page that would only allow pre defined formatting to be entered by the user.
First 3 chars should be from A-Z/a-z.Next 3 chars should be from 0-9.Next 3 chars can be alphanumeric.
Is it doable without javascript or HTML5? If yes, How?
 
Best Answer chosen by Manish Anand 10
Naval Sharma4Naval Sharma4
Hi Manish,

Ignore those brackets. 
Pattern.matches('[A-Za-z]{3}[0-9]{3}[a-zA-Z0-9]{3}', youfFieldValue);   // returns true/false

 

All Answers

Naval Sharma4Naval Sharma4
Hi Manish,

You can use regex in apex controller to validate field data.
Pattern.matches('[A-Za-z]{3}[0-9]{3}[a-zA-Z0-9]{3}', youfFieldValue);   // returns true/false

 
Manish Anand 10Manish Anand 10
Hi Naval,

Thanks for your response.
What does angular brackets <b><i> means in the second parameter? Can't we use just the FieldValue?
Naval Sharma4Naval Sharma4
Hi Manish,

Ignore those brackets. 
Pattern.matches('[A-Za-z]{3}[0-9]{3}[a-zA-Z0-9]{3}', youfFieldValue);   // returns true/false

 
This was selected as the best answer