From 6b04258ef46edcca9f5f76998370c50d6de9cc1f Mon Sep 17 00:00:00 2001 From: Erayd Date: Thu, 31 Oct 2019 12:38:45 +1300 Subject: [PATCH] Truncate maxlength= fields (#189) --- src/inject.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/inject.js b/src/inject.js index c2563f5..845c52b 100644 --- a/src/inject.js +++ b/src/inject.js @@ -411,6 +411,11 @@ el.dispatchEvent(new Event(eventName, { bubbles: true })); } + // truncate the value if required by the field + if (el.maxLength > 0) { + value = value.substr(0, el.maxLength); + } + // Set the field value let initialValue = el.value || el.getAttribute("value"); el.setAttribute("value", value);