Rev 23419 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$().ready(function() {$("form#create-prebooking-order-form input").each(function(){$(this).attr('autocomplete', 'off');});});$().ready(function() {// validate the comment form when it is submitted$('#create-prebooking-order-form').validate({rules:{customerName:{required:true},customerMobileNumber:{required:true},customerEmailId:{required:true}},messages:{customerName:{required:"Please enter the customer name"},customerMobileNumber:{required:"Please enter customer mobile number"},customerEmailId:{required:"Please enter customer email id"}},submitHandler: function (form, event) {event.preventDefault();if(validatePrebookingOrderDetails()){alert("Please fix errors");return false;}var json = prebookingOrderDetailsJson();console.log("schemeJson = " + json);if(confirm("Are you sure you want to create Prebooking Order!") == true){doAjaxRequestWithJsonHandler(context+"/createPrebookingOrder", "POST", json, function(response){$('#main-content').html(response);});return false; // required to block normal submit since you used ajax}}});});function validatePrebookingOrderDetails(){console.log("validating prebooking order details...");var error = false;var customerName = $("form#create-prebooking-order-form input[name=customerName]").val();console.log("customerName = " + customerName);$("#customerName").removeClass("border-highlight");if(customerName == ""){alert("Customer name can not be empty");$("#customerName").addClass("border-highlight");error = true;return error;}var customerMobileNumber = $("form#create-prebooking-order-form input[name=customerMobileNumber]").val();console.log("customerMobileNumber = " + customerMobileNumber);$("#customerMobileNumber").removeClass("border-highlight");if(customerMobileNumber == ""){alert("Customer mobile number can not be empty");$("#customerMobileNumber").addClass("border-highlight");error = true;return error;}var customerEmailId = $("form#create-prebooking-order-form input[name=customerEmailId]").val();console.log("customerEmailId = " + customerEmailId);$("#customerEmailId").removeClass("border-highlight");if(customerEmailId == ""){alert("Customer email id can not be empty");$("#customerEmailId").addClass("border-highlight");error = true;return error;}var quantity = $("form#create-prebooking-order-form input[name=quantity]").val();console.log("quantity = " + quantity);$("#quantity").removeClass("border-highlight");if (quantity == ""){$("form#create-order-form input[name=quantity]").val(1);}else if(tentativeAmount <= 0){alert("quantity should be greater than 0");$("#quantity").addClass("border-highlight");error = true;return error;}console.log("validation prebooking order error = " + error);return error;}function prebookingOrderDetailsJson(){console.log("prebookingOrderDetailsJson");var prebookingOrderObject = {};prebookingOrderObject['customerName'] = $("#customerName").val();prebookingOrderObject['customerMobileNumber'] = $('#customerMobileNumber').val();prebookingOrderObject['customerEmailId'] = $('#customerEmailId').val();var prebookingListing = $('#activePrebookingItemsDescription').val().split(",");prebookingOrderObject['catalogId'] = parseInt(prebookingListing[0]);prebookingOrderObject['quantity'] = $('#quantity').val();return JSON.stringify(prebookingOrderObject);}