Untitled

 avatar
unknown
plain_text
a year ago
693 B
4
Indexable
Validator.register('alphaNumericCheck', function (value, requirement) {
    // Regex to detect HTML tag pattern
    var htmlPattern = /<[^>]+>/;
    // Updated alphanumeric check pattern with additional symbols, including newline characters
    var allowedPattern = /^[a-zA-Z0-9\n…—%&(),.;:'"+\$-“”’•#\/<>@?!]+$/;

    // Check if the value contains HTML tags
    if (htmlPattern.test(value)) {
        throw new Error('Invalid input: contains HTML tags.');
    }

    // Check if the value contains any characters outside the allowed set
    if (!allowedPattern.test(value)) {
        throw new Error('Invalid input: contains disallowed characters.');
    }

    return true;
});
Editor is loading...
Leave a Comment