I'm using the materialize framework. According to the documentation, I can use "autocomplete" in the form tag according to the Materialize Form link. My question, is this I want to create a javascript for autocomplete of extensions, example: @ gmail.com, @ outlook.com, @ hotmail.com. When the user says "@" this list appears. Below my code
<div class="row">
<div class="input-field col l6">
<i class="material-icons prefix">email</i>
<input type="email" id="email" class="validate" autocomplete="off">
<label data-error="E-mail invalido!" data-success="E-mail valido!" for="nome">E-mail</label>
</div>
</div>
Javascript:
<script>
//Função para autocomplete do email
$(document).ready(function(){
//pegando o id do formulario
$('#email').autocomplete({
//Aqui declaro algumas possiveis extensoes de email para autocompletar
data: {
"@hotmail.com": null, /
"@gmail.com": null,
"@outlook.com": "img/outlook.jpg",
},
limit: 20, // The max amount of results that can be shown at once. Default: Infinity.
onAutocomplete: function(val) {
// Função quando é valido ou seja completado!
//alert("ok");
},
minLength: 1, // The minimum length of the input for the autocomplete to start. Default: 1.
});
});
</script>