我有一個文本字段,我檢測到與jQuery的變化,然後我取消/激活一個按鈕,如果價值> 1000(它應該包含一個價格)。 它工作正常。輸入變化檢測不工作,而使用掩碼
現在我想對我的輸入應用掩碼格式值,並限制這樣的人物: 99 999 999,99
面膜是工作,但隨後,修改檢測不工作...
我使用autoNumeric爲我的面具: https://github.com/BobKnothe/autoNumeric
我創建了2個例子與的jsfiddle:
- https://jsfiddle.net/dv75y8h6/ =>工作檢測
- https://jsfiddle.net/pj368dc3/ =>非工作檢測,但工作 面具
這裏是我的javascript代碼:
function activeInvoice(priceField) {
console.log(priceField.val());
var val = (priceField.val() >= 1000);
$('#invoice_file').prop('disabled', !val);
$('#invoice_file').prop('required', val);
}
$(function() {
$('#price').autoNumeric("init", {
aSep: ' ',
aDec: ','
});
var priceField = $('#price');
activeInvoice(priceField);
$(document).on('input', '#price', function() {
activeInvoice($(this));
});
});
我想有兩個工作,當然!
感謝
有關信息,autoNumeric不發送'input'也不'change'事件是得到了[固定](錯誤HTTPS ://github.com/BobKnothe/autoNumeric/issues/292)。您現在可以透明地使用蒙版,而不會干擾默認事件(幾乎; p)。 – Alex