I have an input field currency that is disabled if the value on another field fee is empty or zero.
Html
Fee: <input id="fee"><br>
Currency: <input id="currency"><br>
Javascript
$("#fee").on('input', function() {
$('#currency').prop('disabled', (this.value === '0' || this.value === ''));
})
.trigger('input');
or JSFiddle
What I now try to achieve is that the field currency is also disabled if someone enters 00 or 0.0 or 0,0 which currently is not the case. I have to test for both a . and a , in my field, because users can enter numbers with both values as a delimiter.
I through of changing this.value === '0' to this.value < '0.000000001' || this.value < '0,000000001', but then it still won't work with 00. Also something like 0,1 will be disabled (which it shouldn't), and that is because of the comma , which does not work in a number?
Is there perhaps an easy (or difficult) solution to my problem?
edit to clarify: the field currency should be disabled when the user enters 0, 00 (or any number of zeros), 0.0(or any more zeros) and 0,0(or any more zeros). The field should be enabled if the user enters something like 09 or 0,5 or 0.1.