Using jQuery, how can I add a default value of http:// into an input field that can’t be removed, but that still allows you to type a URL after it?
http://
Defa
All tested!
$('#myUrl').keyup(function(e) { if (this.value.length < 7) { this.value = 'http://'; } else if (this.value.indexOf('http://') !== 0) { this.value = 'http://' + String.fromCharCode(e.which); } });
URL: