Skip to content

Instantly share code, notes, and snippets.

@srkirkland
Created December 21, 2011 23:25
Show Gist options
  • Select an option

  • Save srkirkland/1508183 to your computer and use it in GitHub Desktop.

Select an option

Save srkirkland/1508183 to your computer and use it in GitHub Desktop.
new version of line item validation
purchasing.validateLineItem = function () {
$(".line-item-row").each(function () {
var row = $(this);
var hasQuantity = purchasing.cleanNumber(row.find(".quantity").val()) !== '';
var hasPrice = purchasing.cleanNumber(row.find(".price").val()) !== '';
var hasDescription = row.find(".description").val().trim() !== '';
if (hasQuantity || hasPrice || hasDescription) {
row.find(".quantity").toggleClass("line-item-ok", hasQuantity).toggleClass("line-item-warning", !hasQuantity);
row.find(".description").toggleClass("line-item-ok", hasDescription).toggleClass("line-item-warning", !hasDescription);
row.find(".price").toggleClass("line-item-ok", hasPrice).toggleClass("line-item-warning", !hasPrice);
}
else {
row.find(":input").removeClass("line-item-ok").removeClass("line-item-warning");
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment