Keeping it simple and using the replace function:
var url = "http://http://google.com";
url = url.replace("http://http://","http://");
... this will basically replace the first string "http://http://"
by the second, "http://"
.
You'll need to call this when the content of the field change. For instance using jQuery:
$("#myfield").change(function(e){
$(this).val($(this).val().replace("http://http://","http://"));
});
without jQuery (not 100% sure about this):
document.getElementById("myfield").onChange = function(){
var val=document.getElementById("myfield").value;
document.getElementById("myfield").value = value.replace("http://http://","http://");
}
Unrelated but worth mentioning: This is not AJAX, it is simple javascript. Ajax is the term used when you try to have asynchronous communication with a server using the XMLHTTP object
Ajax (shorthand for asynchronous
JavaScript and XML) is a group of
interrelated web development
techniques used on the client-side to
create interactive web applications.
With Ajax, web applications can
retrieve data from the server
asynchronously in the background
without interfering with the display
and behavior of the existing page.
(via)