提交确认 [英] Confirmation on submit

查看:236
本文介绍了提交确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个向数据库提交信息的表单。我怎样才能这样做,当我点击提交按钮时,我会收到一个警告,询问我是否真的要提交它,当我点击是时它会继续,如果我点击否它就不会提交信息。

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 when I click "Yes" it continues and if I click "no" it does not submit the information.

推荐答案

使用JavaScript confirm() 功能。

Use JavaScript confirm() function.

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

如果用户选择,它将返回 true 并且按钮的默认操作(提交表单)将照常继续。但是如果用户选择,它将返回 false ,并且该按钮的默认操作将被阻止。

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.

这篇关于提交确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆