Welcome Guest, Not a member yet? Register   Sign In
how to handle Multiple form on one page without showing validation errors of both forms.
#1

[eluser]pankaj[/eluser]
I want to put two forms on my front page which are one for "registration of user" and one for "login" like facebook has on its front page but when I submit the page either for registration or login it will show validation errors for both forms can anybody please explain me how to handle both forms at a time without showing errors from both forms. and it should show error for particular form only and not for both forms.
is there any thread on this topic as I can't find one.

please help
thank you.
#2

[eluser]beemr[/eluser]
I attach a true value to the submit button with 'login' or 'register' for the respective submit. Then once the controller confirms that one of these is true it sets the appropriate rules and runs validation.

something like:
Code:
if ($this->input->post('register'))
{
$this->form_validation->set_rules('for','register','form','only');
if ($this->form_validation->run())
{
run registration sequence
} else {
return register errors sequence
}
} else {
this is not the register form
}
#3

[eluser]mello.capinpin[/eluser]
cool! thanks
#4

[eluser]TheFuzzy0ne[/eluser]
If you can post your code, I think I can help. The trick is to test which form is being submitted and only validate that. If no forms are being submitted, no validation should be run.




Theme © iAndrew 2016 - Forum software by © MyBB