Add auto roundup in input field when making payments
This commit is contained in:
@@ -451,4 +451,44 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var input = document.getElementById('txtbayarantawarruq');
|
||||
var timer;
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() {
|
||||
var value = parseFloat(input.value);
|
||||
if (!isNaN(value)) {
|
||||
input.value = value.toFixed(2);
|
||||
}
|
||||
}, 500); // 500ms delay
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var inputs = document.querySelectorAll('input[name="txtbayarantawarruq"]');
|
||||
|
||||
Array.from(inputs).forEach(function(input) {
|
||||
var timer;
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() {
|
||||
var value = parseFloat(input.value);
|
||||
if (!isNaN(value)) {
|
||||
roundedValue = (value * 100) / 10;
|
||||
roundedValue = Math.round(roundedValue);
|
||||
roundedValue = roundedValue / 10;
|
||||
input.value = roundedValue.toFixed(2);
|
||||
}
|
||||
}, 1500); // 1500ms delay
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user