Confirmation on submit

后端 未结 1 1941
無奈伤痛
無奈伤痛 2020-12-11 21:53

I have a form that submits information to a database. How can I make it so that when I click the submit button, I get an alert that asks me if I really want to submit it and

相关标签:
1条回答
  • 2020-12-11 22:09

    Use JavaScript confirm() function.

    <input type="submit" onclick="return confirm('Are you sure?')">
    

    If the user chooses Yes, it will return true and the button's default action (submitting the form) will continue as usual. But if the user chooses No, it will return false and the button's default action will be blocked.

    0 讨论(0)
提交回复
热议问题