在下面的代码中,我在 id "phone_world" 上附加了 onChange() 事件,并在其上应用了输入掩码。输入桅杆工作正常,但未调用现有事件和 hello 函数。
<div class="demo">
<input type="text" id="phone_world" onChange = "hello()" value="" size="25">
<label for="phone_world" id="descr_world">Страны мира</label>
<script>
var listCountries = $.masksSort($.masksLoad("https://cdn.rawgit.com/andr-04/inputmask-multi/master/data/phone-codes.json"), ['#'], /[0-9]|#/, "mask");
var maskOpts = {
inputmask: {
definitions: {
'#': {
validator: "[0-9]",
cardinality: 1
}
},
showMaskOnHover: false,
autoUnmask: true,
clearMaskOnLostFocus: false
},
match: /[0-9]/,
replace: '#',
listKey: "mask"
};
var maskChangeWorld = function(maskObj, determined) {
if (determined) {
var hint = maskObj.name_ru;
if (maskObj.desc_ru && maskObj.desc_ru != "") {
hint += " (" + maskObj.desc_ru + ")";
}
$("#descr_world").html(hint);
} else {
$("#descr_world").html("Страны мира");
}
}
$('#phone_world').inputmasks($.extend(true, {}, maskOpts, {
list: listCountries,
onMaskChange: maskChangeWorld
}));
function hello(){
alert('hi');
}
</script>