mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
Ensure only valid non-negative numbers in tip input (#4481)
close #4478
This commit is contained in:
parent
09d5f5a083
commit
03d7dc8971
3 changed files with 19 additions and 3 deletions
|
@ -80,7 +80,15 @@
|
|||
<th colspan="5" class="border-0">
|
||||
<div class="input-group mb-2">
|
||||
<span class="input-group-text"><i class="fa fa-money fa-fw"></i></span>
|
||||
<input class="js-cart-tip form-control form-control-lg" type="number" min="0" step="@Model.Step" value="{tip}" name="tip" placeholder="Tip in @(Model.CurrencyInfo.CurrencySymbol != null ? Model.CurrencyInfo.CurrencySymbol : Model.CurrencyCode)">
|
||||
<input
|
||||
class="js-cart-tip form-control form-control-lg"
|
||||
type="number"
|
||||
min="0"
|
||||
step="@Model.Step"
|
||||
value="{tip}"
|
||||
name="tip"
|
||||
placeholder="Tip in @(Model.CurrencyInfo.CurrencySymbol != null ? Model.CurrencyInfo.CurrencySymbol : Model.CurrencyCode)"
|
||||
/>
|
||||
<a class="js-cart-tip-remove btn btn-lg btn-danger" href="#"><i class="fa fa-times"></i></a>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
|
|
|
@ -137,8 +137,17 @@ $(document).ready(function(){
|
|||
cart.updateSummaryProducts();
|
||||
cart.updateSummaryTotal();
|
||||
|
||||
var $tipInput = $('.js-cart-tip');
|
||||
$tipInput[0].addEventListener('input', function(e) {
|
||||
var value = parseFloat(e.target.value)
|
||||
if (Number.isNaN(value) || value < 0) {
|
||||
e.target.value = '';
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
// Change total when tip is changed
|
||||
$('.js-cart-tip').inputAmount(cart, 'tip');
|
||||
$tipInput.inputAmount(cart, 'tip');
|
||||
// Remove tip
|
||||
$('.js-cart-tip-remove').removeAmount(cart, 'tip');
|
||||
|
||||
|
|
|
@ -340,7 +340,6 @@ Cart.prototype.updatePosData = function() {
|
|||
tip: this.tip? this.tip: 0,
|
||||
total: this.getTotal(true)
|
||||
};
|
||||
console.warn(result);
|
||||
$('#js-cart-posdata').val(JSON.stringify(result));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue