0

here HTML

    <form action="" method="get">
                <input type="text" placeholder="Họ" id="inputHo"><br>
                <span id="annouceHo"></span><br>
                <input type="submit" id="btnSubmit">
    </form>

here JAVASCRIPT

    var annouceHo= document.getElementById("annouceHo");
    var  btnSubmit= document.getElementById("btnSubmit");
    btnSubmit.onclick=checkValuation();
    function checkValuation(){
    inputHo= document.getElementById("inputHo").value;
    if (inputHo==""){
        // alert("check");
        annouceHo.innerHTML="first name cant empty";
      } 
    }

**the function checkValuation alway run althought i didnt call it by click button. **

  • i find out proplem : function checkValuation all run beacause : when i write checkValuation (). i only call with checkValuation. without (). – SƠN HOÀNG ĐÌNH Jun 09 '23 at 06:54

0 Answers0