i have installed the WebForms module for Magento from VladimirPopov , so i want to use the validate function in my custom module
this is the file in vendor module :
...
...
...
Object.extend(Validation, {
validate: function (elm, options) {
options = Object.extend({
useTitle: false,
onElementValidate: function (result, elm) {
if (this.maxDate) {
this.maxDate = new Date(this.maxDate);
this.minDate.setHours(0);
if (isNaN(this.maxDate)) {
this.maxDate = new Date();
}
validate = validate && (this.fullDate <= this.maxDate);
}
if (this.maxDate && this.minDate) {
this.validateDataErrorText = 'Please enter a valid date between %s and %s';
} else if (this.maxDate) {
this.validateDataErrorText = 'Please enter a valid date less than or equal to %s';
} else if (this.minDate) {
this.validateDataErrorText = 'Please enter a valid date equal to or greater than %s';
} else {
this.validateDataErrorText = '';
}
}
return validate;
},
return Validation;
})
...
...
...
this is how i call the validation inside my js file :
define([
'VladimirPopov_WebForms/js/validation',
'jquery',
'mage/storage',
'mage/translate',
'Magento_Customer/js/customer-data',
'jquery/ui'
], function (vladimirValidation,$, storage, $t, customerData) {
'use strict';
...
...
...
$('#form-validate.form-address-edit').bind('mouseup keyup change', function (event) {
if (event.target.tagName === 'INPUT' && (event.type === 'keyup' || event.type === 'change')) {
$("#" + event.target.id + "").vladimirValidation.validate();
}
});
is this the proper way to call the validate() function please ?