Can't Validate Checkout. Ajax form for addresses is ignoring JQuery Validation
Since the Billing and Shipping form generated by the Checkout Wizard (Payments Advanced) is an Ajax form, validation is ignored because the address form closes when you click "Continue" no matter what the validation status is.
At first I thought maybe this was an error on my part (still might be) so I created a test site with nothing in it.
1)- Created eCart object and a single static item with Add To Cart.
2)- Then used Checkout Wizard with all basic default settings but used PayPal Advanced for the payment method.
When tested, the Billing and Shipping addresses were left blank, but when I click "Continue" the forms slide up and the PayPal hosted page appears in an iframe.
I see the tooltip error messages for a split second, so I know the validation is happening, but the forms disappear and the buyer is left with the option to go ahead and pay.
What I have tried:
Figuring that maybe the Checkout Wizard generated pages that had some errors and might be causing this, I opened the WA forms JQuery Validation and clicked OK.
For some reason the JQuery Validation window deletes part of the code created by the Checkout Wizard. This causes the constant spinning wheel and "Please Wait…" message that I asked about in this thread. http://www.webassist.com/forums/post/185422/
This is the code at the bottom of the checkout.php page as created by the Checkout Wizard.
<script src="webassist/forms/wa_servervalidation.js" type="text/javascript"></script>
<script src="webassist/forms/wa_clientvalidation.js" type="text/javascript"></script>
<script src="webassist/forms/WA_SameAs.js" type="text/javascript"></script>
<script src="webassist/jq_validation/jquery.h5validate.js"></script>
<script>
var CheckoutWizard_NewFromBlank_Default_Opts = {
focusout: true,
focusin: false,
change: false,
keyup: false,
popupClass: "Default",
pointedAt: "right",
fieldOffset: -2,
fieldMargin: 0,
position: "left",
direction: "left",
border: 1,
offset: 25,
closeText: "✖",
percentWidth: 100,
orientation: "bottom"
};
function CheckoutWizard_NewFromBlank_Default_Validate() {
$("#CheckoutWizard_NewFromBlank_Default").h5Validate(CheckoutWizard_NewFromBlank_Default_Opts);
}
$(document).ready(function () {
CheckoutWizard_NewFromBlank_Default_Validate()
ConvertServerErrors(CheckoutWizard_NewFromBlank_Default_Opts);
});
</script>
<script src="webassist/framework/javascript/ajax.js" type="text/javascript"></script>
<script type="text/javascript" src="webassist/ecart/checkout/js/paymentoptions.js"></script>
<script>
function framework_load_plugin_url(plugin,form,div,framework_path,on_success) {
framework_ajax_plugin(form,plugin,div,framework_path,false,false,on_success);
return true;
}
var wa_form_id = "CheckoutWizard_NewFromBlank_Default";
var wa_cart_page = "confirm_cart.php";
var wa_framework_path = "";
var wa_confirm_page = "confirm.php";
</script>
And this is what is left after simply clicking OK in the JQ Forms Validation dialog window.
<script src="webassist/forms/wa_servervalidation.js" type="text/javascript"></script>
<script src="webassist/forms/wa_clientvalidation.js" type="text/javascript"></script>
<script src="webassist/forms/WA_SameAs.js" type="text/javascript"></script>
<script src="webassist/jq_validation/jquery.h5validate.js"></script>
<script>
var CheckoutWizard_NewFromBlank_Default_Opts = {
focusout: true,
focusin: false,
change: false,
keyup: false,
popupClass: "Default",
pointedAt: "right",
fieldOffset: -2,
fieldMargin: 0,
position: "left",
direction: "left",
border: 1,
offset: 25,
closeText: "✖",
percentWidth: 100,
orientation: "bottom"
};
function CheckoutWizard_NewFromBlank_Default_Validate() {
$("#CheckoutWizard_NewFromBlank_Default").h5Validate(CheckoutWizard_NewFromBlank_Default_Opts);
}
$(document).ready(function () {
CheckoutWizard_NewFromBlank_Default_Validate()
ConvertServerErrors(CheckoutWizard_NewFromBlank_Default_Opts);
});
</script>
As you can see, it removes the reference to ajax.js and paymentoptions.js and the framework function.
I really think two things are at play here. One is that JQuery Forms Validation is conflicting with the code created by the Checkout Wizard. And secondly, the code that is suppose to block the form from being submitted if it doesn't validate is not working with the Ajax since the same action also closes the address forms.
Any thoughts on this? I have this on my local test server or I would include a URL. This was a new generic shopping cart in an empty site with no other code added.
Thanks,
TroyD