validate quantity when printing labels

This commit is contained in:
Lance Edgar 2012-08-01 06:02:15 -07:00
parent 6212932f74
commit 9a8c647b25

View file

@ -40,7 +40,11 @@
$(function() { $(function() {
$('div.grid.Product a.print-label').live('click', function() { $('div.grid.Product a.print-label').live('click', function() {
var quantity = $('#label-quantity').val(); var quantity = $('#label-quantity').val();
// TODO: Validate quantity as integer etc. if (isNaN(quantity)) {
alert("You must provide a valid label quantity.");
$('#label-quantity').select();
$('#label-quantity').focus();
} else {
$.ajax({ $.ajax({
url: '${url('products.print_label')}', url: '${url('products.print_label')}',
data: { data: {
@ -49,7 +53,12 @@
'quantity': quantity, 'quantity': quantity,
}, },
}); });
alert("Label has been printed."); if (quantity == '1') {
alert("1 label has been printed.");
} else {
alert(quantity + " labels have been printed.");
}
}
return false; return false;
}); });
}); });