Login-Register Form (Pill) with Flask - error on register ta

Topic: Login-Register Form (Pill) with Flask - error on register tab does not redirect back to register tab, but instead to login tab

stevenpj pro premium priority asked a year ago

Hi – I’m using the tabbed Login/Registration form with a Python-Flask project and am using WTFORMS for form validation. When I encounter an error where one of my form fields does not meet certain criteria, I redirect to the login form page. This works fine for the login tab, but when I encounter an error on the register tab, it redirects to the login page where the login tab is highlighted.

Is there anyway to redirect to the login page and highlight the second tab – the registration? When I do click on the register tab, it does show my errors, but that makes for a bad user experience to have to click back to the register tab.

Any thoughts?

Michał Duszak staff answered a year ago

Have you tried show option to toggle register tab right after the site is loaded?

You can also use it in classes, like in this snippet: https://mdbootstrap.com/snippets/standard/m-duszak/3080220


stevenpj pro premium priority answered a year ago

Thanks for the info. making the page default is not a problem from js or within the html, but I'm trying to do it on submission error out and redirecting to the same page to display the error. My python is:

return render_template('login.html',register_form=register_form, login_form=login_form)

Grzegorz Bujański staff commented a year ago

You can use the public show method. Have you tried to use the show method to toggle the tab when an error is returned?

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.5.1
  • Device: mabbook
  • Browser: chrome
  • OS: macOS Big Sur
  • Provided sample code: No
  • Provided link: No