Answers for "div contenteditable maxlength reactjs"

1

div contenteditable maxlength reactjs

const maxLength = 12
const onKeyDwn = (e: any) => {
        const currentTextLength = e.target.outerText.length;
        if (currentTextLength === maxLength && e.keyCode != 8) {
            e.preventDefault();
        }
}


<div onKeyDown={onKeyDwn} contentEditable={true} ></div>
Posted by: Guest on August-09-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language