BPM: Custom text area with max length

 View Only
Tue September 01, 2020 12:00 PM

im on bpm 8.5.6 and using mainly IE 9 as browser. I need to set the maxlength attribute of a textArea (i used the one provided in the coaches toolkit and tried fiddling with it) to 1000. However, i cant seem to get it. i tried locating the textArea tag in the html once the view is loaded...
#Featured-area-2
#Featured-area-2-home

Comments

Mon September 14, 2020 02:16 PM

Hi,
The maxlength attribute is not supported on IE9. You'll have to implement a solution in javascript. You could try something like:

var textarea = document.querySelector("textarea"); var onPaste = function onPaste(event) { var len = parseInt(this.getAttribute("maxlength"), 10); if (this.value.length + window.clipboardData.getData("Text").length > len) { this.value = this.value.substr(0, len); return false; } } var onTextInput = function onTextInput(event) { return (this.value.length < 10); } textarea.onpaste = onPaste; textarea.onkeypress = onTextInput;


I don't have an IE9 browser to test this on and so I am concerned about accessing the clipboard in the paste function. You may have to change the code a bit.

Hope this helps.