Login and Registration Form in HTML | CodingNepal

HTML Nested Form

In this article, we will see if can we create a nested form in HTML. Creating multiple forms within a form using tag is called a nested form. But we can’t create nested forms. Even if we create a nested form, it will automatically create separately. Let’s see an example:

html nested form

In this example code, we have created a form and inside it another form. Outside the form, we have gotten a “Name” input and created a “Submit” button. Inside the inner form, we have gotten “Email”, and “Password” and created a “Submit” button.

html nested form

See the above output, outer and inner form is successfully displayed. But see the element’s output below:

The child form is automatically merged with the parent form. Understand that, even if we create a nested form it will be merged, So we can create forms separately like:

Here, we have created two forms separately. This also gives us the same output. So, if you want to create a group form together, you need to use the or tags.

In summary, although it is possible to create a nested form in HTML, it may cause browser compatibility issues and is not recommended as it violates the HTML specification. It’s best to use other HTML elements to group related form elements together

Источник

Как отправить из html формы только часть данных

Бывает ситуация, когда нужно отправить форму с данными, которая уже вложена в другую форму. Обычно потребности могут быть при написании админской части web-приложения. Но вложенные формы стандартом HTML не допускаются. Вложенная форма при этом не работает. Предлагаем два метода решения данной проблемы.

Первый способ

В этом случае обработка и сортировка поступившей информации ложится целиком на сторону сервера. Сначала определяем какая из кнопок была нажата, затем на основании этой информации из всех данных выбираются нужные. Данный метод универсален с точки зрения работы в любой среде, работает во всех случаях, даже если у пользователя в браузере отключены скрипты. Недостаток способа в том, что передаются все поля из формы, а не только нужные.

Читайте также:  Проверить true или false python

Второй способ

Этот способ заключается в том, что из формы берутся нужные поля, затем динамически формируется новая форма и отправляется на сервер. Для этого придется сделать несколько вспомогательных действий. Разметка страницы может разная, мы укажем такую:

  //-------------------------------------------------------------------- // Создать временную форму и перенести в нее все элементы //-------------------------------------------------------------------- function ds(f) < var e=document.getElementById(f); if (!e) return false; // Создать временную форму var tmp_form = document.createElement("form"); tmp_form.method='get'; tmp_form.action='process.php'; // Адрес скрипта-обработчика формы tmp_form.style.display='none'; document.getElementsByTagName('body')[0].appendChild(tmp_form); // Перенести в нее все элементы cf(e,tmp_form); // Отправить созданную форму tmp_form.submit(); >//-------------------------------------------------------------------- // Перенести значения полей в форму //-------------------------------------------------------------------- function cf(e,f) < for (var i=0; i// Флажок checkbox case 'checkbox': < if (el.checked) < var tmp_el = document.createElement("input"); tmp_el.name=el.name; tmp_el.type='checkbox'; tmp_el.value=el.value; f.appendChild(tmp_el); tmp_el.checked=true; >break; > // Флажок radio case 'radio': < if (el.checked) < var tmp_el = document.createElement("input"); tmp_el.name=el.name; tmp_el.type='radio'; tmp_el.value=el.value; f.appendChild(tmp_el); tmp_el.checked=true; >break; > // Текстовое поле case 'hidden': < var tmp_el = document.createElement("input"); tmp_el.name=el.name; tmp_el.type='hidden'; tmp_el.value=el.value; f.appendChild(tmp_el); break; >// Поле ввода пароля case 'password': < var tmp_el = document.createElement("input"); tmp_el.name=el.name; tmp_el.type='hidden'; tmp_el.value=el.value; f.appendChild(tmp_el); break; >// Любые другие input'ы default: < break; >> > // Обработка textarea else if (elName=='textarea' && el.name!='') < var tmp_el = document.createElement("textarea"); tmp_el.name=el.name; tmp_el.value=el.value; f.appendChild(tmp_el); >// Обработка select else if (elName=='select' && el.name!='') < var tmp_el = document.createElement("input"); tmp_el.name=el.name; tmp_el.type='hidden'; tmp_el.value=el.value; f.appendChild(tmp_el); >else < // Обработать вложенный тег (рекурсия) cf(el,f); >> > 

© 2008 — 2022, ELsof.ru. Создание и поддержка сайтов. Раскрутка сайтов. Разработка Android приложений. Php скрипты

Источник

Login and Registration Form in HTML CSS & JavaScript

Login & Registration Form HTML & CSS

Hey friends, today in this blog, you’ll learn how to create an Animated Login and Registration Form in HTML CSS & JavaScript. Earlier I shared many blogs on How to Create a Login Form using HTML & CSS but, I haven’t shared a particular blog related to Login and Registration Forms in HTML. So, it’s time to create this one.

In this Form (Login and Registration Form in HTML), on the webpage, there is a login form and two toggle buttons at the top of the form labeled Login and Signup as you can see in the preview image above.

When you click on the signup button, the login form smoothly slides from the right to the left side and shows you the signup form.

Читайте также:  Redirect page in html button

And again after clicking the login button, the signup form slide from the left to the right side and shows you the login form. In this form, the login and signup forms both are on the same page and it is done with a little bit of JavaScript codes.

If you’re feeling difficult to understand what I am saying, you can watch a full video tutorial of this form (Login and Registration Form in HTML).

Video Tutorial of Login and Registration Form in HTML

In the video, you have seen an animated Login and Registration Form that is created using HTML CSS & JavaScript. I hope you’ve understood the basic codes behind creating this form.

I used just a few lines of JavaScript codes to complete this form, so you can easily create this type of login and registration form in HTML even if you’re a beginner.

JavaScript is used only to slide the form on button click and the toggle tab that slides from login to signup text and signup to login text is wholly based on pure HTML & CSS with the help of HTML tag.

If you liked this login form and want to get source codes or files, you can get them from the bottom of this page.

You might like this:

Login and Registration Form in HTML [Source Codes]

To create this form (Login and Registration Form in HTML). First, you need to create two Files one HTML File and another one is CSS File. After completing these files paste the following codes into your file.

First, create an HTML file with the name index.html and paste the given codes into your HTML file. Remember, you’ve to create a file with a .html extension.

        
Login Form
Signup Form
Forgot password?
Not a member? Signup now

Second, create a CSS file with the name style.css and paste the given codes into your CSS file. Remember, you’ve to create a file with a .css extension.

@import url(‘https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap’); * < margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; >html,body < display: grid; height: 100%; width: 100%; place-items: center; background: -webkit-linear-gradient(left, #a445b2, #fa4299); >::selection < background: #fa4299; color: #fff; >.wrapper < overflow: hidden; max-width: 390px; background: #fff; padding: 30px; border-radius: 5px; box-shadow: 0px 15px 20px rgba(0,0,0,0.1); >.wrapper .title-text < display: flex; width: 200%; >.wrapper .title < width: 50%; font-size: 35px; font-weight: 600; text-align: center; transition: all 0.6s cubic-bezier(0.68,-0.55,0.265,1.55); >.wrapper .slide-controls < position: relative; display: flex; height: 50px; width: 100%; overflow: hidden; margin: 30px 0 10px 0; justify-content: space-between; border: 1px solid lightgrey; border-radius: 5px; >.slide-controls .slide < height: 100%; width: 100%; color: #fff; font-size: 18px; font-weight: 500; text-align: center; line-height: 48px; cursor: pointer; z-index: 1; transition: all 0.6s ease; >.slide-controls label.signup < color: #000; >.slide-controls .slider-tab < position: absolute; height: 100%; width: 50%; left: 0; z-index: 0; border-radius: 5px; background: -webkit-linear-gradient(left, #a445b2, #fa4299); transition: all 0.6s cubic-bezier(0.68,-0.55,0.265,1.55); >input[type=»radio»] < display: none; >#signup:checked ~ .slider-tab < left: 50%; >#signup:checked ~ label.signup < color: #fff; cursor: default; user-select: none; >#signup:checked ~ label.login < color: #000; >#login:checked ~ label.signup < color: #000; >#login:checked ~ label.login < cursor: default; user-select: none; >.wrapper .form-container < width: 100%; overflow: hidden; >.form-container .form-inner < display: flex; width: 200%; >.form-container .form-inner form < width: 50%; transition: all 0.6s cubic-bezier(0.68,-0.55,0.265,1.55); >.form-inner form .field < height: 50px; width: 100%; margin-top: 20px; >.form-inner form .field input < height: 100%; width: 100%; outline: none; padding-left: 15px; border-radius: 5px; border: 1px solid lightgrey; border-bottom-width: 2px; font-size: 17px; transition: all 0.3s ease; >.form-inner form .field input:focus < border-color: #fc83bb; /* box-shadow: inset 0 0 3px #fb6aae; */ >.form-inner form .field input::placeholder < color: #999; transition: all 0.3s ease; >form .field input:focus::placeholder < color: #b3b3b3; >.form-inner form .pass-link < margin-top: 5px; >.form-inner form .signup-link < text-align: center; margin-top: 30px; >.form-inner form .pass-link a, .form-inner form .signup-link a < color: #fa4299; text-decoration: none; >.form-inner form .pass-link a:hover, .form-inner form .signup-link a:hover < text-decoration: underline; >form .btn < height: 50px; width: 100%; border-radius: 5px; position: relative; overflow: hidden; >form .btn .btn-layer < height: 100%; width: 300%; position: absolute; left: -100%; background: -webkit-linear-gradient(right, #a445b2, #fa4299, #a445b2, #fa4299); border-radius: 5px; transition: all 0.4s ease;; >form .btn:hover .btn-layer < left: 0; >form .btn input[type=»submit»]

That’s all, now you’ve successfully created a Login and Registration Form in HTML CSS & JavaScript. If your code doesn’t work or you’ve faced any error/problem then please download the source code files from the given download button. It’s free and a .zip file will be downloaded then you’ve to extract it.

Источник

Оцените статью