[Vtigercrm-developers] Field Validator classes?
Alan Lord
alanslists at gmail.com
Mon Apr 9 09:29:12 GMT 2018
It's "kind of" working but I can't work out how to replace the error
message...
In my custom javascript library during the "registerEvents()" call I
have added a new function called setValidators().
> setValidators : function() {
> jQuery.validator.methods.phone = function(value, element, params) {
> try {
> if(!value) return true;
> var tenDigitRegex = /(^[0-9]{10})$/ ;
> var result = tenDigitRegex.test(value);
> if (!result) {
> return false;
> }
> return true;
> } catch(err) {
> console.log(err);
> return false;
> }
> }, function(params, element) {return app.vtranslate('Number must be 10 digits only')}
> },
This indeed now validates all phone fields to be 10 digits only, which
is what I want. But the error message is coming from the the vtiger
validation file so when you try and enter an invalid value into the
field it says
> "Please enter the correct date"
How do I replace the error message without changing core files?
According to the docs maybe I can't...
https://jqueryvalidation.org/jQuery.validator.methods/
TIA
Al
On 09/04/18 09:36, Alan Lord wrote:
> I was looking to port a mod I have made to a validator in the
> modules/Vtiger/resources/validator/FieldValidator.js file from vtiger 6
> to vtiger 7.
More information about the vtigercrm-developers
mailing list