To add a validator to an element, you will need to open
process.php and find the code that creates the element you want to add the validator to. It may already have a line below it that is calling
addValidators(), in that case just add the name of the validator you want to add at the end of the array that is passed in. If the element had the following code.
You can just add another line below that adds the new validator. For example if you wanted to add the digits validator also you can make the code:
You could also use the following code (note the method name is addValidators instead of addValidator above)
You can also instantiate the validator directly then add it to the element. Which may help with your own custom validators if you need to make any that you need to pass options to, for example.