利用OnClientClick事件彈出選項提示框

當咱們點擊一按鈕,想要彈出一雙選擇提示框時,能夠採用如下方法:javascript

<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" />java

<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>spa

注:在function內添加您您本身的代碼server

而後再cs中的onclick 事件"Button1_Click"下添加以下代碼:事件

ClientScript.RegisterStartupScript(Page.GetType(), "jskey", "alert('')", true);

ip

相關文章
相關標籤/搜索