Skip to content

Commit

Permalink
WFK2-793 Fix booking validation for mobiles.
Browse files Browse the repository at this point in the history
Not all ticket categories should have positive booking numbers.
Only the ones input by users should have positive number of
requested tickets.
  • Loading branch information
VineetReynolds committed Nov 17, 2014
1 parent 25154dd commit 0e842e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 5 additions & 6 deletions tutorial/UserFrontEnd.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0e842e7

Please sign in to comment.