本文介绍了如何从.ascx中的文本框和主页上的Updatepanek获取Jquery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 < asp:textbox ID =Telephonetextboxcssclass =inputrunat =serveronkeyup =f_a(this); Text ='<%#Bind(telephone)%>'AutoPostBack =true/> <asp:textbox ID="Telephonetextbox" cssclass="input" runat="server" onkeyup="f_a(this);" Text='<%# Bind("telephone") %>' AutoPostBack="true"/><script type="text/javascript"> $(document).ready(function () { Sys.WebForms.PageRequestManager.getInstance().add_endRequest(f_a); f_a(this); }); function f_a(v_id) { return document.getElementById(v_id); $(document).ready(f_a(this)); } var obj = document.getElementById("#<%=fmAuthRoles.FindControl("Telephonetextbox").ClientID %>"); f_a(obj).maxLength = 14; f_a(obj).keyup = function (v_e) { v_e = v_e || window.event; if (v_e.keyCode >= 65 && v_e.keyCode <= 90) { this.value = this.value.substr(0, this.value.length - 1); return false; } else if (v_e.keyCode >= 37 && v_e.keyCode <= 40) { return true; } var v_value = (this.value.replace(/[^\d]/g, '')); if (v_value.length == 7) { this.value = (v_value.substring(0, 3) + "-" + v_value.substring(3, 7)); } else if (v_value.length == 10) { this.value = ("(" + v_value.substring(0, 3) + ") " + v_value.substring(3, 6) + "-" + v_value.substring(6, 10)); }; }</script> 推荐答案 这篇关于如何从.ascx中的文本框和主页上的Updatepanek获取Jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 03:07