View Full Version : validation failing
geordie728
06-01-2009, 02:39 PM
for some reason on my checkout.php page (attached) my validation isn't checking for some reason.
it's quite happy to pass the data to the confirm.php page but not check that all form fields have been completed.
I've only tried to validate the billing info so far (I had everything working fine previously) so don't know what the issue is.
Any ideas appreciated.
Seems to be one step forward, 2 steps back at the minute.
Thanks,
G
Dave Buchholz
06-02-2009, 12:43 AM
Your form will not validate because the form action is pointing at confirm.php, consequently the form values are passed directly to confirm.php bypassing your current validation.
You can solve this by validating your ecart_checkout_form form on your confirm.php page. To do this you need to expose the ecart_checkout_form values on confirm.php and you do this by using the Form Data option under Bindings and choose checkout.php as the page where the post is coming from then you can open up validation toolkit server behaviour as normal.
One tip make sure that on error you transfer back to checkout.php and have your error messages there rather than on confirm.php.
geordie728
06-02-2009, 02:12 AM
It was working before which is what I don't get. I'd like to get it working that way because the workflow makes sense for users.
Also if the validation is done on confirm.php then what purpose does checkout.php serve?
Dave Buchholz
06-02-2009, 03:18 AM
If it was working before you cannot have had the action of the form set to confirm.php, once the action is set the form will post it's contents to the page set in the action, if the action is blank then it will post to itself that is the way all html forms work regardless of whether they are in a php, asp or cf page.
The users do not need to know where the validation is set as if they make a mistake they will see checkout.php pop up with the validation errors you set.
The workflow is to collect the necessary info on checkout.php pass it to confirm.php if all is good display confirm.php if not bounce them back to checkout.php and display the error messages you set with validation toolkit.
There is a "completed" store in the downloads for ecart that would be worth you looking at to see how this is set-up
geordie728
06-02-2009, 04:45 AM
That's the default form action when you run the checkout wizard.
The workflow you describe is exactly how it was working before.
Customer hits checkout > if not logged in, ask them to login > display the checkout.php page and if details exist for user, display them in the form > run server validation, if validation fails then display errors, if validation passes then display confirm.php
I didn't change my approach after re-doing my checkout.php validation so I don't know why it's not working.
I had a look at the completed store but neither checkout.php or confirm.php has any server validation on it.
Dave Buchholz
06-02-2009, 05:03 AM
The validation on checkout.php will never run whilst the form action is set to confirm.php, you need to place the validation server behaviour on confirm.php for this to work as you want.
geordie728
06-02-2009, 07:02 AM
OK - if I go back to your earlier post about exposing the ecart_checkout_form on confirm.php to run server validation there, is the validation trigger set to before page load?
Dave Buchholz
06-02-2009, 07:11 AM
No you would set it to your submit button as normal
geordie728
06-02-2009, 07:21 AM
how does that work then because if you're validating the form on checkout.php via confirm.php and you're not validating until the submit button is pressed (there's only 1 on the confirm.php and that is to submit your order) then you would want to validate at that stage, not before the user hits to submit their order?
Dave Buchholz
06-02-2009, 07:38 AM
you set the validation to fire on the submit button from the form checkout.php page, once you have exposed the form as I explained earlier you will find the button in your bindings panel as normal
geordie728
06-02-2009, 12:18 PM
works fine doing it before confirm.php loads so that's fine.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.