I have a simple login form with username/email and password fields, and two buttons, one for a normal login and one for LDAP login.
The normal login requires email/pwd, while the LDAP login requires username/pwd
I already have it working with a input-text field but I’ve discovered that input-email helps mobile user to have a specialized keyboard with @ and . as shortcuts.
What’s the easiest way to achieve that mobile friendly keyboard? My idea was to somehow use input-email and disable validation, but I’d still like to maintain the automatic "required" validation
<div class="form-floating">
<input required autofocus type="text" class="form-control"
id="username" name="username" placeholder="username or email">
<label for="username">username or email</label>
</div>
Ignore bootstrap for the purpose of the final result 🙂
2
Answers
Set the initial type to email (have the benefit of user friendly keyboard) and alter the type on button click to text/email accordingly to remove the restriction on submit if needed:
The solution by Ali Sheikhpour will display the invalid message when you press Enter in the empty field and then continue typing:
So the direction could be to imitate the email input in a shadow DOM. Works in the mobile Chrome. Should be tweaked for Firefox/Safari.