Skip to content

Instantly share code, notes, and snippets.

@gRegorLove
Created July 29, 2015 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gRegorLove/3e17532d0c01114a1f0e to your computer and use it in GitHub Desktop.
Save gRegorLove/3e17532d0c01114a1f0e to your computer and use it in GitHub Desktop.
// usage: onblur="absoluteURL(this);" on HTML5 'url' input
function absoluteURL(url) {
var string = url.value;
if ( string != '' && !(string.match(/^https?:/)) ) {
string = 'http://' + string;
}
else if (string == 'http://' || string == 'https://' )
{
string = '';
}
url.value = string;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment