In my custom validation rules shows ‘
Uncaught TypeError: Cannot read property ‘call’ of undefined’ errors!!!…
. how can i do custom logic and proper validation ?
Here is my Code
app/code/{vendor}/{module}/view/frontend/web/template/form/element/email.html
<input class="input-text" type="text" data-bind=" textInput: email, hasFocus: emailFocused, mageInit: {'mage/trim-input':{}}" name="username" data-validate="{required:true,'validate-custom-key':true}" id="customer-email" />
app/code/{vendor}/{module}/view/frontend/requirejs-config.js
// JavaScript Document var config = { map: { '*': { script: 'Vendor_Module/js/script' }, '*': { 'Vendor_Module/js/action/login': 'Vendor_Module/js/action/login' }, '*': { 'Magento_Checkout/template/form/element/email.html': 'Vendor_Module/template/form/element/email.html' } }, mixins: { 'Magento_Ui/js/lib/validation/validator': { 'Vendor_Module/js/validator-mixin': true } } };
app/design/frontend/Smartwave/porto/web/js/validator-mixin.js
define([ 'jquery' ], function ($ ) { "use strict"; return function () { $ .validator.addMethod( 'validate-custom-key', function (value) { // Some custom validation stuff here return false; }, $ .mage.__('Your validation error message') ); } });
jquery.validate.js:556 Uncaught TypeError: Cannot read property ‘call of undefined
at $ .validator.check (jquery.validate.js:556)
at $ .validator.checkForm (jquery.validate.js:372)
at $ .validator.form (jquery.validate.js:359)
at HTMLFormElement. (jquery.validate.js:90)
at HTMLFormElement.dispatch (jquery.js:5226)
at HTMLFormElement.elemData.handle (jquery.js:4878) check @
jquery.validate.js:556 checkForm @ jquery.validate.js:372 form @
jquery.validate.js:359 (anonymous) @ jquery.validate.js:90 dispatch @
jquery.js:5226
elemData.handle @ jquery.js:4878