This topic is locked
[SOLVED]

 how can I change input type for username in login page

8/12/2020 12:24:17 AM
PHPRunner General questions
Myr0n author

Hello
Recently I changed the way to log in, from user authentication to authenticate with email.

Everything works fine, until I realized that the input type is as text and not as email.
I did some research and found that the only way to change the type of an input is to create it again.this is the code that works:

$( "#username" ).each(function() {

$("<input type='email' />").attr({ name: this.name, value: this.value }).insertBefore(this);

}).remove();


Unfortunately it loses all the nice attributes of the original input, it remains a simple input.

How can I create again without losing attributes?

Has anyone encountered this type of situation?

In the designer when choosing the field "username" in common pages, login does not appear the option "View As / Edit As" to change the type.

You may wonder why you need to change it?

In mobile devices that do not have a physical keyboard such as tablets or smartphones, if an input field is email, the keyboard that will show will be the normal keyboard plus the @ sign and a period.

Thank you so much in advance.

Sergey Kornilov admin 8/18/2020

It should be doable without deleting and creating the input control again, check this:

https://stackoverflow.com/questions/16699165/how-to-change-the-input-type-property-in-jquery

Myr0n author 8/18/2020

It works with

$('input:text').prop('type','email');



Awesome, thank you so much.