how to add a validation message for only one particular field in a pdp ,quick, view and edit cart page
first we need to cerate a event for this and we can get the value from configuration for particular field which we want then we can perform the operation on it other wise if already event is there u want that work only on the one field then we should set id and write a event on it.
events: {
'change #in-modal-custcol_ag_routingnumber': 'validation'
},
validation: function (e) {
try {
let currentID = e.currentTarget.name;
let itemOptions = SC.CONFIGURATION.productConfigurator.optionsConfiguration;
let currentOption = _.filter(itemOptions, function (option) {
if (option.configuratorLabelsCartOptionId == currentID) {
return option.pattern;
};
});
let pattern = currentOption[0].pattern;
pattern = new RegExp(pattern)
if (!(pattern.test(e.currentTarget.value))) {
e.currentTarget.value = "";
if (e.currentTarget.nextSibling == null) {
let global_view_message = '<span class="global-views-message global-views-message-error alert">' +
currentOption[0].validation + '</span>'
$(global_view_message).insertAfter("#" + e.currentTarget.id);
$("#" + e.currentTarget.id).css('border-color', '#c01a29');
};
} else {
$("#" + e.currentTarget.id).css('border-color', '#999');
if (e.currentTarget.nextSibling) {
e.currentTarget.nextSibling.remove();
};
};
} catch (e) {
console.log("validation issue", e);
}
},