<asp:TextBox ID=”txtTel” runat=”server” CssClass=”MustInputText” Width=”164″ AutoPostBack=”true”
OnTextChanged=”txtTel_TextChanged” onkeydown=”check(this);” onkeyup=”check(this);” onchange=”return check(this);”></asp:TextBox>
function check( tel ){
var e = window.event
//alert(e.keyCode);
if (e.keyCode == 8 ||e.keyCode ==46 || e.keyCode == 35 ||e.keyCode ==36||e.keyCode ==37||e.keyCode ==38||e.keyCode ==39||e.keyCode ==40 ){
//避免backspace,delete,上、下、左、右、home,end不可用
}else{
tel.value = tel.value.replace(” “,”").replace(“\\”,”,”).replace(“-”,”").replace(“”,”").replace(“(“,”").replace(“)”,”").replace(“(”,”").replace(“)”,”").replace(“、”,”,”).replace(“,”,”,”);
//alert(tel.length);
tel.focus();
if (tel.value.length>8){
setTimeout(‘__doPostBack(\’txtTel\’,\’\')’, 0);
}}
}
上一篇: HTML radio指定相同name,则为互斥关系
下一篇: js含多个引号单引号时可用转义符