Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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>
 
PREVIOUS NEXT
Tagged: #div #contenteditable #maxlength #reactjs
ADD COMMENT
Topic
Name
3+8 =