I want to create an autocomplete feature for the input field on my website. For instance, when the tab key is pressed, I want the word htt
to automatically become tp://
in the input value.
This autocomplete should only work if the user inputs "htt" at the start of the URL.
My initial idea was to use a regular expression to validate the autocompletion:
if(event.keyCode == 9){
if(myInput.value.match(/^(h|ht|htt|http|http:|http:\/)/)){
myInput.value = "http://";
}
}
However, the actual outcome was not as expected...