JSFiddle - React, Tailwind, and code Playground
HTML
Email ID: <input type="text" id="autocomplete" />
JavaScript
$(document).ready(function() {
var autocompOpts = {
minChars:0,
matchSubset:false,
matchContains: true,
source : []
};
var domains = [
"@gmail.com",
"@yahoo-inc.com",
"@yahoo.com",
"@yahoo.co.in",
"@rediff.com",
"@rediffmail.com",
"@hotmail.com",
"@msn.com"
];
var input = $("#autocomplete");
input.autocomplete(autocompOpts);
input.bind('keyup', function(event) {
if (event.shiftKey == 1 && event.keyCode == 50) {
var userName = $(this).val();
userName = userName.substring(0, userName.length - 1);
$.each(domains, function(index,domain){
autocompOpts.source.push(userName + domain);
});
$(this).autocomplete(autocompOpts);
}
});
});