MessageBox带有yes no或取消按钮 [英] MessageBox with yes no or cancel button

查看:449
本文介绍了MessageBox带有yes no或取消按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type = "text/javascript">

    function Confirm()
    {
        var confirm_value = document.createElement("INPUT");
        confirm_value.type = "hidden";
        confirm_value.name = "confirm_value";
        if (confirm("Do you want to save data?")) {
            confirm_value.value = "Yes";
        } else {
            confirm_value.value = "No";
        }
        document.forms[0].appendChild(confirm_value);
    }

</script>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:TextBox ID="TextBox1" runat="server" BackColor="White" BorderColor="White" 
BorderStyle="Groove" Width="157px"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" style="font-size: medium; font-weight: 700; font-style: italic" Text="Submit" onclick="Button1_Click" OnClientClick="Confirm()" />







I am using this code when click on Submit Button MessageBox is appear but it does not check Required Field Validator.

推荐答案

我想你想在必要的字段验证器验证输入后显示消息框。

从onClientClick调用它的表单的onsibmit调用Confirm()函数。

如下所示对代码进行一些更改;



I think you want to show the message box after required field validater validates the input.
Call the Confirm() function from onsibmit of the form instaed of calling it from onClientClick.
Do a little change in your code as below;

<form id="form1" runat="server" onsubmit="Confirm()><br mode=" hold=" /></form></pre><br mode="></form>


这篇关于MessageBox带有yes no或取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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