From 0e842e778263621061032f3bc835c73abbe897ad Mon Sep 17 00:00:00 2001 From: Vineet Reynolds Date: Mon, 17 Nov 2014 13:07:36 +0530 Subject: [PATCH] WFK2-793 Fix booking validation for mobiles. Not all ticket categories should have positive booking numbers. Only the ones input by users should have positive number of requested tickets. --- .../resources/js/app/views/desktop/create-booking.js | 4 ++-- .../resources/js/app/views/mobile/create-booking.js | 7 +++---- tutorial/UserFrontEnd.asciidoc | 11 +++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/demo/src/main/webapp/resources/js/app/views/desktop/create-booking.js b/demo/src/main/webapp/resources/js/app/views/desktop/create-booking.js index 180a15bdc..e64ea5449 100644 --- a/demo/src/main/webapp/resources/js/app/views/desktop/create-booking.js +++ b/demo/src/main/webapp/resources/js/app/views/desktop/create-booking.js @@ -55,10 +55,10 @@ define([ || value <= 0 // is negative || parseFloat(value) != parseInt(value))) { // is not an integer $("#error-input-"+ticketPriceId).empty().append("Please enter a positive integer value"); - $("#ticket-category-fieldset-"+ticketPriceId).addClass("error") + $("#ticket-category-fieldset-"+ticketPriceId).addClass("error"); } else { $("#error-input-"+ticketPriceId).empty(); - $("#ticket-category-fieldset-"+ticketPriceId).removeClass("error") + $("#ticket-category-fieldset-"+ticketPriceId).removeClass("error"); } // are there any outstanding errors after this update? // if yes, disable the input button diff --git a/demo/src/main/webapp/resources/js/app/views/mobile/create-booking.js b/demo/src/main/webapp/resources/js/app/views/mobile/create-booking.js index a87bd7bc3..30414997b 100644 --- a/demo/src/main/webapp/resources/js/app/views/mobile/create-booking.js +++ b/demo/src/main/webapp/resources/js/app/views/mobile/create-booking.js @@ -147,15 +147,14 @@ define([ this.model.email = $("input[type='email']").val(); $("input[type='number']").each(function(idx,element) { var quantity = $(this).val(); - if(!$.isNumeric(quantity) // is a non-number, other than empty string + if(quantity.length > 0 && + (!$.isNumeric(quantity) // is a non-number, other than empty string || quantity <= 0 // is negative - || parseFloat(quantity) != parseInt(quantity)) { + || parseFloat(quantity) != parseInt(quantity))) { $("#error-" + element.id).empty().append("Should be a positive number."); - $('a[id="confirmBooking"]').removeClass('ui-disabled'); valid = false; } else { $("#error-" + element.id).empty(); - $('a[id="confirmBooking"]').addClass('ui-disabled'); } }); try { diff --git a/tutorial/UserFrontEnd.asciidoc b/tutorial/UserFrontEnd.asciidoc index 9a298cf2c..249e2080f 100644 --- a/tutorial/UserFrontEnd.asciidoc +++ b/tutorial/UserFrontEnd.asciidoc @@ -983,10 +983,10 @@ define([ || value <= 0 // is negative || parseFloat(value) != parseInt(value))) { // is not an integer $("#error-input-"+ticketPriceId).empty().append("Please enter a positive integer value"); - $("#ticket-category-fieldset-"+ticketPriceId).addClass("error") + $("#ticket-category-fieldset-"+ticketPriceId).addClass("error"); } else { $("#error-input-"+ticketPriceId).empty(); - $("#ticket-category-fieldset-"+ticketPriceId).removeClass("error") + $("#ticket-category-fieldset-"+ticketPriceId).removeClass("error"); } // are there any outstanding errors after this update? // if yes, disable the input button @@ -2215,15 +2215,14 @@ define([ this.model.email = $("input[type='email']").val(); $("input[type='number']").each(function(idx,element) { var quantity = $(this).val(); - if(!$.isNumeric(quantity) // is a non-number, other than empty string + if(quantity.length > 0 && + (!$.isNumeric(quantity) // is a non-number, other than empty string || quantity <= 0 // is negative - || parseFloat(quantity) != parseInt(quantity)) { + || parseFloat(quantity) != parseInt(quantity))) { $("#error-" + element.id).empty().append("Should be a positive number."); - $('a[id="confirmBooking"]').removeClass('ui-disabled'); valid = false; } else { $("#error-" + element.id).empty(); - $('a[id="confirmBooking"]').addClass('ui-disabled'); } }); try {