Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
693 B
1
Indexable
Never
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;
});
Leave a Comment