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() {
$('div.grid.Product a.print-label').live('click', function() {
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({
url: '${url('products.print_label')}',
data: {
@ -49,7 +53,12 @@
'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;
});
});