i'm using following code remove "http://" , "https://" user entered/pasted url in textbox:
$('input.url-input').change( function() { var textbox = $(this); if (textbox.val().indexof("http://") == 0) textbox.val(textbox.val().substring(7)); if (textbox.val().indexof("https://") == 0) textbox.val(textbox.val().substring(8)); });
my problem works in browsers, including ie9 & ie10, not in ie8.
i'm new javascript , appreciate help.
many in advance!
works in ie7,8 use jquery <= 1.10.x not 2.0.x
$('input[type=text].input-url').change( function(event) { var $input, url; $input = $(this); url = $input.val(); $input.val(url.replace(/^(http(s)?:\/\/)/i,'')); });
or short
$('input[type=text].input-url').change( function(event) { $(this).val($(this).val().replace(/^(http(s)?:\/\/)/i,'')); });
Comments
Post a Comment