I have a setup like, My website ask the user for entering a URL. Sometimes user enters like http://google.com/ and other times google.com, but my application supports URL with http:// or https://,
I tried this:
var a = document.getElementById('tinput').value;
if (a.indexOf(escape('http://')) < 0 && a.indexOf(escape('https://')) < 0){
b = 'http://' + a;
document.getElementById('tinput').value = b;
}
document.getElementById("urlfrm").submit();
But this dint work. It always adds http:// to all the URL even if they contain the same. What to do?