input email with default @ jquery

0

I need to create an input email that will keep the "@" character by default and without being able to erase in addition to writing in front of the "@" and behind it, can this be done? thank you very much

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<input type="email" id="myEmail" value="@">
    
asked by Javier Antonio Aguayo Aguilar 24.08.2017 в 21:30
source

1 answer

-1

This one serves me ami.

$("input").keydown(function(e) {
    var oldvalue=$(this).val();
    var field=this;
    setTimeout(function () {
        if(field.value.indexOf('@') !== 0) {
            $(field).val(oldvalue);
        } 
    }, 1);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="email" value="@" />
    
answered by 24.08.2017 в 21:35