当我们点击一按钮,想要弹出一双选择提示框时,可以采用以下方法:
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="Large"
Height="34px" onclick="Button1_Click" OnClientClick="return f_check_IP()"
Text="添加记录" Visible="False" Width="150px" />
<script language="javascript" type="text/javascript">
function f_check_IP() {
var msg = "您真的确定要添加新纪录吗?\n\n请确认!";
var shi = document.getElementById('Text2').value;
var now_goods = document.getElementById('Text3').value;
var a = /^[a-zA-Z][a-zA-Z]\d\d\d\d\d\d\d\d\d$/;
var b = /^[a-zA-Z][a-zA-Z]\d\d\d\d\d\d\d\d\d(_|\/)(\d{1,4})([a-zA-Z][a-zA-Z])(-|\/)(\d{1,4})$/;
if (1) {
if (now_goods != 0) {
if (a.exec(now_goods)) {
if (confirm(msg) == true) {
return true;
}
else {
return false;
}
}
else {
if (b.exec(now_goods)) {
if (confirm(msg) == true) {
return true;
}
else {
return false;
}
}
else {
alert("来料批号或者生产批号格式错误,请重新输入!");
document.getElementById("Text3").value = "";
document.getElementById("Text3").focus();
return false;
}
}
}
else {
if (confirm(msg) == true) {
return true;
}
else {
return false;
}
}
}
else {
alert("卡号(10进制)输入有错!请输入1--9999999999的整数!");
document.getElementById("Text2").value = "";
document.getElementById("Text2").focus();
return false;
}
}
</script>
注:在function内添加您您自己的代码
然后再cs中的onclick 事件"Button1_Click"下添加如下代码:
ClientScript.RegisterStartupScript(Page.GetType(), "jskey", "alert('')", true);
来源:oschina
链接:https://my.oschina.net/u/818427/blog/169642