From 4f8d7b9a8e50fcc2c1a459e4ebfaee3978e4dd85 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Wed, 27 Sep 2017 11:25:25 -0700 Subject: Prevent user from submitting an incomplete form. When the user didn't finish adding a test acknowledgment, refocus on the first incomplete field instead of saving. Test: staging Bug: 67001652 Change-Id: I889f32cd53838e109f222aaed10e91d7d7c60e96 --- src/main/webapp/js/test_acknowledgments.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/main/webapp/js/test_acknowledgments.js b/src/main/webapp/js/test_acknowledgments.js index 8c5d837..da47870 100644 --- a/src/main/webapp/js/test_acknowledgments.js +++ b/src/main/webapp/js/test_acknowledgments.js @@ -151,6 +151,18 @@ * @param note (String) The note in the acknowledgment. */ function saveCallback(ack, modal, key, test, branchSet, deviceSet, testCaseSet, note) { + var allEmpty = true; + var firstUnemptyInput = null; + var vals = modal.find('.modal-section>.input-container>input').each(function(_, input) { + if (!!$(input).val()) { + allEmpty = false; + if (!firstUnemptyInput) firstUnemptyInput = $(input); + } + }); + if (!allEmpty) { + firstUnemptyInput.focus(); + return false; + } var branches = Array.from(branchSet); branches.sort(); var devices = Array.from(deviceSet); -- cgit v1.2.3