I’m trying set fixed email mask, but it’s not working…
<div class="wrap-input100 validate-input" data-validate = "Digite seu usuário">
<input class="email input100 <?php echo (!empty($user_erro)) ? 'is-invalid' : ''; ?>" type="text" name="usuario">
<span class="focus-input100" data-placeholder="Email"></span>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script>
<script>
$(document).ready(function(){
$('.email').mask('*{A}@test.com.br', {'translation': { "A": { pattern: /[w@-.+]/, recursive: true }},reverse: true});
});
</script>
If fixes at one char only "/ I need unlimited, but i don’t know what i’m doing wrong.
2
Answers
Solved.
Snippet with code below:
I suggest you default your input to
[email protected]
. When a user focuses the field, select the username so that when the user starts typing they’ll overwrite the user but the domain name will stay intact.Implementing what you want and not losing default behavior of a text field can be very hard. Your current solution breaks a lot of the existing behavior of input fields such as DELETE, arrows, ctrl+a, shift+arrow, …