diff --git a/src/components/Form.js b/src/components/Form.js index 95c53b29e18d..ef6c3ea10474 100644 --- a/src/components/Form.js +++ b/src/components/Form.js @@ -140,11 +140,15 @@ function Form(props) { // Validate the input for html tags. It should supercede any other error _.each(trimmedStringValues, (inputValue, inputID) => { + // If the input value is empty OR is non-string, we don't need to validate it for HTML tags + if (!inputValue || !_.isString(inputValue)) { + return; + } const foundHtmlTagIndex = inputValue.search(CONST.VALIDATE_FOR_HTML_TAG_REGEX); const leadingSpaceIndex = inputValue.search(CONST.VALIDATE_FOR_LEADINGSPACES_HTML_TAG_REGEX); - // Return early if there is no value OR the value is not a string OR there are no HTML characters - if (!inputValue || !_.isString(inputValue) || (leadingSpaceIndex === -1 && foundHtmlTagIndex === -1)) { + // Return early if there are no HTML characters + if (leadingSpaceIndex === -1 && foundHtmlTagIndex === -1) { return; }