Show Different HTML Form On Radio Button Selection

Last Updated on August 5, 2022 by Roshan Parihar

In this tutorial, learn how to show and hide different HTML form on radio button selection. The short answer is to use the val() function along with show() and hide() function.

When the user selects the radio button, upon each selection, a new form will open. Each time, the user will see a different form that you can use for multiple login systems. You can also use this for multiple registration systems.

Show Different HTML Form On Radio Button Selection

There are three radio buttons and three forms available in the below example. When you choose the option, its matching login form will open.

You have to first add forms in different <div> elements with different ids. After that, use the val() function to get the id of <div> elements to display different forms. The show() and hide() function show and hide forms when required.

Test it Live

Output


Subscriber Login
Employee Login
Manager Login

Subscriber Login Form






Employee Login Form






Manager Login Form






Click any of the above-given radio buttons to get the relevant form. When you choose a button, you will get a new form to use for your users.

If you have multiple types of users, employees, and managers log in, you can use this form for your project. It’s the easiest method that uses jQuery to show form dynamically.

Each form is of a different style with the submit button. You can change the above-given forms as per your requirement.

You may also like to read

I hope you like this post on how to show different HTML forms on radio button selection.

References