I created a new validation role (testcaractere_speciaux_street) to eliminate specific spatial characters for the two fields address and address complement in the interface of the add address (customer account). the role works fine in the address field because it contains the “required-entry” class and doesn’t work in the complement address field because this field is optional and doesn’t contain the “required-entry” class NB: if I add the “required-entry” class to the additional Address field, the problem is solved but this is not the case because this field must be optional
<div class="form-group required"><label for="street_1" class="form-label"><span class="required">*</span>Adresse</label><input id="street_1" type="text" name="street[]" value="" class="form-control required-entry testcaractere_speciaux_street"></div><div class="form-group"><label class="form-label" for="street_2"><span>Adresse ( complément )</span></label><input type="text" name="street11" value="" id="street_2" class="form-control testcaractere_speciaux_street"></div>
"testcaractere_speciaux_street": [
function (value) {
var validator = this;
var format =/[`!@#$%^&*()_+=[]{};.':"\|<>/?~]/;
return !format.test(value);
}, $.mage.__('Les caractères autorisés : A-Z a-z 0-9 - ,')
],
please help me, I want the role (testcaractere_speciaux_street) to work well on the additional address field without adding the “required-entry” class.