diff --git a/rattail/pyramid/templates/products/index.mako b/rattail/pyramid/templates/products/index.mako index 17933a73..10f43824 100644 --- a/rattail/pyramid/templates/products/index.mako +++ b/rattail/pyramid/templates/products/index.mako @@ -40,16 +40,25 @@ $(function() { $('div.grid.Product a.print-label').live('click', function() { var quantity = $('#label-quantity').val(); - // TODO: Validate quantity as integer etc. - $.ajax({ - url: '${url('products.print_label')}', - data: { - 'uuid': get_uuid(this), - 'profile': $('#label-profile').val(), - 'quantity': quantity, - }, - }); - alert("Label has been printed."); + if (isNaN(quantity)) { + alert("You must provide a valid label quantity."); + $('#label-quantity').select(); + $('#label-quantity').focus(); + } else { + $.ajax({ + url: '${url('products.print_label')}', + data: { + 'uuid': get_uuid(this), + 'profile': $('#label-profile').val(), + 'quantity': quantity, + }, + }); + if (quantity == '1') { + alert("1 label has been printed."); + } else { + alert(quantity + " labels have been printed."); + } + } return false; }); });