Created
December 21, 2011 23:25
-
-
Save srkirkland/1508183 to your computer and use it in GitHub Desktop.
new version of line item validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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