how to get the function to execute validations function & th
Posted: Sun Feb 02, 2014 11:46 am
I have this on click function, that I need to add another function inside of to do a pause and finish, and then resume the onclick function to continue.
-function to call and pause : errorCheckingOrder(). see below
Here is function onclick:
And here is the function for doing the error checking/validations. Which we need to go thru first, then once good. Continue. the function above.
Please help how we get, the validations to go thru first, then run the payment_order on click function????
-function to call and pause : errorCheckingOrder(). see below
Here is function onclick:
Code: Select all
$('#payment_submit_order').on('click', function(){
errorCheckingOrder();//here is the function calling it
var data = {fName : $("#returnfirstName").val(), lName: $("#returnlastName").val(), add1: $("#returnaddress1").val(), add2: $("#returnaddress2").val()};
data.city = $("#returncity").val();
data.state = $("#returnstate").val();
data.mail = $("#returnemail").val();
data.zipcode = $("#returnzipcode").val();
var returnAddress = saveAddress(data);
var value = $('input[name=shippingType]:checked').val();
if(value == 0){
var address = saveAddress();
var shipping = ($('input[name=shippingmethod]:checked').val()*productCart.length).toFixed(2);
for(var i in productCart) {
productCart[i].addressId = address;
productCart[i].shippingmethod = shipping;
productCart[i].returnAddress = returnAddress;
}
}else{
for(var i in productCart) {
var address = $("#selectProductAddress_"+productCart[i].uProductID).val();
productCart[i].addressId = address;
productCart[i].returnAddress = returnAddress;
var shipping = 0;
$('input[name^="shippingmethod_"]').each(function(){
if($(this).is(":checked")){
shipping += parseFloat($(this).val());
}
});
shipping = shipping.toFixed(2);
productCart[i].shippingmethod = shipping;
}
}
});
Code: Select all
//Personlize & Customize Validation placed here
$(function errorCheckingOrder(){
bindValidation("shipping_gift_card","${pageContext.response.locale}");
$("#payment_submit_order").click(function(){
return isValidation("shipping_gift_card","${pageContext.response.locale}");
});
});