Changing background color of text box input not working when empty

前端 未结 8 2048
半阙折子戏
半阙折子戏 2020-12-29 07:37

I am having a tough time with this javascript code to change the background color of a text input if the input is empty.

Here is the code:

function c         


        
8条回答
  •  天涯浪人
    2020-12-29 07:58

    Try this:

    function checkFilled() {
    var inputVal = document.getElementById("subEmail");
    if (inputVal == "") {
        inputVal.style.backgroundColor = "yellow";
        }
    }
    

提交回复
热议问题