Form validation with redirect |
What is the url to your form? I'm assuming it is /home and your post url is /home/send. If this is the case then you are defining you rules in the send method and you then validate your posted form.
Define your rules in the home method and do your validation in your home method. Your post URL would then be /home#anchor instead of /home/send. If the validation fails, the view with your form and errors is loaded and the #anchor wil take you to your form. No need for JavaScript. If the form passed validation you could redirect to your send method and save the post dataset in a flashdata for processing in your send method. PHP Code: class Home extends CI_Controller { Maybe my example can help you on your way. In my example the problem of double form posting is also solved |
Welcome Guest, Not a member yet? Register Sign In |