簡體   English   中英

使用jQuery在modal中設置輸入掩碼

[英]Set input mask inside modal using jQuery

我只需要從下拉列表中選擇一些值時屏蔽輸入。 我設法調用javascript函數表單代碼,后面將調用jquery。 當我顯示警報時,它工作正常。 當我試圖屏蔽輸入時(模態加載后,從下拉列表中選擇值)我的模態消失了,我無法點擊任何地方。

需要屏蔽的輸入字段:

<input id="txt_debtor_phone" name="txt_debtor_phone" placeholder="Phone" class="form-control txt_debtor_phone frm_debtor_request" runat="server" />

在滿足條件時從代碼調用JS函數:

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mask_phone_number", "javascript:mask_phone_number();", true);

模態內的JS函數:

function mask_phone_number() {
            jqueryfunction("I am here");
            //alert("hello");
        }

模態內的jQuery函數:

$(document).ready(function () { 
            jqueryfunction = function (test) {
               // alert(test);
                $('input[name=txt_debtor_phone]').mask('000-000-000');
            }
});

將.modal-backdrop類屬性更改為none

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM