我有这个HTML
<input name="telefone" id="telefone" class="f1 easyui-textbox" data-options="required:true" />
这个js代码:
$('#telefone').textbox({
onChange:function(v){
var r = v.replace(/\D/g,"");
r = r.replace(/^0/,"");
if (r.length > 11) {
// 11+ digits. Format as 5+4.
r = r.replace(/^(\d\d)(\d)(\d{4})(\d{4}).*/,"($1)$2.$3-$4");
}
else if (r.length > 6) {
// 6..10 digits. Format as 4+4
r = r.replace(/^(\d\d)(\d)(\d{0,4})(\d{0,4}).*/,"($1)$2.$3-$4");
}
else if (r.length >= 3) {
// 3..5 digits. Add (0XX..)
r = r.replace(/^(\d\d)(\d)(\d{0,5})/,"($1)$2.$3");
}
else {
// 0..2 digits. Just add (0XX
r = r.replace(/^(\d*)/, "($1");
}
if (r != v) {
$('#telefone').textbox('setText',r);
}
}
});
这个工作非常好但是onChange就像onblur一样工作我希望它像onkeyup一样工作。所以我尝试了这个:
$("#telefone").keyup(function() { alert("ok"); });
和这个
$("#telefone").on("keyup",function(){ alert('ok'); });
没有成功= /
有人,请!!?!?!?
答案 0 :(得分:-1)
为我工作:
$('#Razon').textbox({
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keypress:function(e){
return soloLetras(e);
}
})
})