I am using this mixin for the custom validation rules in the below template for the first and last name
Template:
/vendor/magento/module-customer/view/frontend/templates/widget/name.phtml
require js :
var config = {
config: {
mixins: {
'mage/validation': {
'Magento_Customer/js/name-validation': true
}
}
}
}
Js file :
require(
[
‘Magento_Ui/js/lib/validation/validator’,
‘jquery’,
‘mage/translate’
], function(validator, $){
‘use strict’;
validator.addRule(
'validate-checkname',
function (value) {
let checkComma = value.includes(',');
return !checkComma;
},
$.mage.__("Please enter valid name avoid using comma")
);
return validator;
});
But not working when I edit the first name and last name with the comma in the customer Address Book edit.