JavaScript Form Submit - Confirm or Cancel Submission Dialog Box

前端 未结 6 1417
一生所求
一生所求 2020-11-22 15:13

For a simple form with an alert that asks if fields were filled out correctly, I need a function that does this:

  • Shows an alert box when button is clicked w

6条回答
  •  名媛妹妹
    2020-11-22 15:36

    If you want to apply some condition on form submit then you can use this method

    One thing always keep in mind that method and action attribute write after onsubmit attributes

    javascript code

    function checkEmpData()
    {
      var a = 0;
    
      if(a != 0)
      {
        return confirm("Do you want to generate attendance?");
      }
       else
       {
          alert('Please Select Employee First');
          return false;
       }  
    }
    

提交回复
热议问题