JavaScript Form Submit - Confirm or Cancel Submission Dialog Box

前端 未结 6 1428
一生所求
一生所求 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:41

    OK, just change your code to something like this:

    
    
    

    Also this is the code in run, just I make it easier to see how it works, just run the code below to see the result:

    function submitForm() {
      return confirm('Do you really want to submit the form?');
    }

提交回复
热议问题