I have these two functions
$("#card-personalize-text").on('change keyup', function () {
if (!unsupportedCharsAlertShown && checkDoesTextIncludesUnexpectedCharacters()) {
alert(unsupportedCharsMessage);
unsupportedCharsAlertShown = true;
}
});
function checkDoesTextIncludesUnexpectedCharacters(text) {
console.log(text);
console.log(/^[A-Za-z0-9/?!.:(){}]*$/.test(text));
return (/^[A-Za-z0-9/?!.:(){}]*$/.test(text));
}
For some reason checkDoesTextIncludesUnexpectedCharacters
return false all of the time.
Even when console.log(text);
print text. For example ‘Test’ text return false
What is strange if I Hardcode text when call function, for example
if (!unsupportedCharsAlertShown && checkDoesTextIncludesUnexpectedCharacters('Test'))
checkDoesTextIncludesUnexpectedCharacters
work and return true.
1