On Jan 20, 10:06 pm, Chris <chris95...@yahoo.comwrote:
Is there a way when a user fills out a form and it asks them to enter
a website that it'll be reformatted with http:// in front of it if it
isn't already there. i.e. domain.com would becomehttp://domain.com
buthttp://example.comwould be left alone.
If you have a guarantee that all resources will be for http protocol
exclusively and not for http or https or ftp or news etc. Otherwise
this helper becomes a great annoyance.
<input type="text" name="URL" onblur="
if (this.value.indexOf('http://') != 0) {
this.value = 'http://' + this.value;
}">
but really what you _should_ do is to simply pre-fill the input with
http://
<input type="text" name="URL" value="http://">
If visitor has http resource to share then she will appreciate your
care. If it's another type of resource then user will simply delete
the helper and type/paste whatever is really needed.