i'm new to js so i have a simple html element that has contenteditable="true" which i'm using as an input box. i want the innerhtml to change to "CAN'T BE EMPTY" when the user has typed nothing in the input box ( " " ) and apparently it doesn't work, any tips on how i can do it? this is my code (which is not working):
HTML:
<p contenteditable="true" id="myparagraph">Input</p>
JS:
if(document.getElementById("myparagraph").innerHTML == ""){
document.getElementById("myparagraph").innerHTML = "CAN'T BE EMPTY";}
i've also tried using the LENGTH property, but didn't work either:
var plength = document.getElementById("myparagraph").innerHTML;
var plength2 = plength.length;
if(plength2 == 0){
document.getElementById("myparagraph").innerHTML = "CAN'T BE EMPTY";}