js点击按钮后判断input内容

各位大佬请问js在一个输入框中输入文本后点击按钮后如果输入的东西等于某个东西就执行另一个东西该怎么写?拜托拜托,先谢谢了!


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<input type="text" name="内容" id="ip1" onblur="test()"/>
<button id="btnSave">提交</button>
</body>
<script>
    var oldInput; //旧的输入,全局变量
 
    function test() {
        var newInput = document.getElementById("ip1").value;//新的输入
        if(newInput == oldInput){ //输入同样的内容
            //禁用提交按钮
            document.getElementById("btnSave").setAttribute("disabled", true);//设置不可点击
        }else{
            document.getElementById("btnSave").removeAttribute("disabled");//去掉不可点击
            oldInput = newInput; //赋新值
        }
    }
</script>
</html>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <input type="text" name="内容" id="inpVal" />
    <button id="btn">按钮</button>
  </body>
  <script>
    document.querySelector("#btn").onclick = function () {
      var inpVal = document.getElementById("inpVal").value;
      if (inpVal == "123") {
        alert("输入123,接下来要执行操作");
      } else {
        console.log("未输入123,要做的事情");
      }
    };
  </script>
</html>

img