[Vtigercrm-developers] Field Validator classes?
Alan Lord
alanslists at gmail.com
Mon Apr 9 08:36:58 GMT 2018
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.
The jQuery class style of validator seems to have disappeared completely.
Looking in various fields in v7 I see nothing in the validator json
array but I do see various "data-rule..." attributes.
These seem to be set using Javascript, but I can't find where the
validation test itself is carried out.
For example, in a phone field there is a data attribute:
> data-rule-phone="true"
But if I grep the source for "rule-phone" I find nothing. (Grepping for
"phone" is pretty pointless as it returns so many results)
An email field has the following attributes:
> data-rule-email="true"
> data-rule-illegal="true"
I found this email rule referenced in a few places using grep including
in layouts/v7/modules/Vtiger/resources/validation.js
In the same file I did find a validator for "phone" - but it does
nothing (also note it has the wrong error message which isn't even
translated):
> jQuery.validator.addMethod("phone", function(value, element, params) {
> try {
> return true;
> } catch(err) {
> console.log(err);
> return false;
> }
> }, jQuery.validator.format("Please enter the correct date")
> );
But I think I can do something with this now. So my question is really
about the jQuery.validator.addMethod call.
Looking at the jQuery.validator documentation I can't see anything like
a $.validator.deleteMethod(name); type call. So is it possible to
extend/override from a custom Javascript library or do I have to modify
the validation.js file?
TIA
Al
More information about the vtigercrm-developers
mailing list