fix changes for taglelong and only have 0 and 5 for two decima places
This commit is contained in:
@@ -502,7 +502,7 @@
|
||||
var max_teller = total_nilai_marhun * (pinjaman_teller/100);
|
||||
var max_pelulus = total_nilai_marhun * (pinjaman_pelulus/100);
|
||||
$('#pembiayaan_max_teller').val(formatter.format(max_teller));
|
||||
$('#pembiyaan_max_pelulus').val(formatter.format(max_pelulus));
|
||||
$('#pembiyaan_max_pelulus').val(formatter.format(max_pelulus.toFixed(2)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
Pembiayaan
|
||||
</div>
|
||||
<div class="col-7 input-group">
|
||||
<input type="text" class="form-control" name="pinjaman" id="pinjaman">
|
||||
<input type="text" class="form-control" onkeypress="return validateFloatKeyPress(this,event);" name="pinjaman" id="pinjaman">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text span-pinjaman">0 %</span>
|
||||
</div>
|
||||
@@ -458,8 +458,8 @@
|
||||
$('.span-pinjaman-max').text(formatter.format(pinjaman_teller) + ' %');
|
||||
var max_teller = total_nilai_marhun * (pinjaman_teller/100);
|
||||
var max_pelulus = total_nilai_marhun * (pinjaman_pelulus/100);
|
||||
$('#pembiayaan_max_teller').val(formatter.format(max_teller));
|
||||
$('#pembiyaan_max_pelulus').val(formatter.format(max_pelulus));
|
||||
$('#pembiayaan_max_teller').val(formatter.format(max_teller.toFixed(2)));
|
||||
$('#pembiyaan_max_pelulus').val(formatter.format(max_pelulus.toFixed(2)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1243,5 +1243,51 @@
|
||||
$('#nilaimarhun_edit').val(formatter.format(total));
|
||||
}
|
||||
|
||||
function validateFloatKeyPress(el, evt) {
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
var number = el.value;
|
||||
let keypress = evt.key;
|
||||
|
||||
// Split the current value by dot to check the number of decimal places
|
||||
var numberParts = number.split('.');
|
||||
|
||||
// Check if the pressed key is a valid character for a floating-point number
|
||||
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if there is already a dot, and the pressed key is another dot
|
||||
if (numberParts.length > 1 && charCode == 46) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the caret position in the input field
|
||||
var caratPos = getSelectionStart(el);
|
||||
|
||||
// Get the position of the existing dot
|
||||
var dotPos = el.value.indexOf(".");
|
||||
|
||||
// Check if the caret is after the existing dot, and there are more than 2 digits after the dot
|
||||
if (caratPos > dotPos && dotPos > -1 && (numberParts[1] && numberParts[1].length > 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the last digit is not 5 or 0, disallow the input
|
||||
if (numberParts[1] && numberParts[1].length === 1 && !['0', '5'].includes(keypress)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getSelectionStart(o) {
|
||||
if (o.createTextRange) {
|
||||
var r = document.selection.createRange().duplicate()
|
||||
r.moveEnd('character', o.value.length)
|
||||
if (r.text == '') return o.value.length
|
||||
return o.value.lastIndexOf(r.text)
|
||||
} else return o.selectionStart
|
||||
}
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user