kiwo123
251
5
Laravel

Check which form error(s) belong to

Posted 2 years ago by kiwo123

I wonder if there is any way I can check which form my error(s) belong to?

At the page /login a login form is displayed, but the user can also click on a register button which will toggle a jquery animation hiding the login form then showing the registration form. - So I have both login and registration on the same page.

The only problem is if I try to register and fail the validation the page will reload with the errors and showing them inside a div, but the page loads with the login form displayed and the registration form hidden which looks odd coz then you have to click on the register button again to show the register form.

So is there any way to check which form the errors belongs to so i can fire a jquery function to show the register form when the page loads?

Or even better, can I redirect to a new page with the registation form shown from start when I get a validation error?

My controller code for register:

public function createUser(NewUserRequest $request) ..... return redirect('/');

Please sign in or create an account to participate in this conversation.