I have a text field for a user to enter a URL. When I call the form data with PHP I’m adding the http:// into the link like this: <a href=“http://’ . $url . '”>
I’m wondering if javascript can help me check to see if the user has entered the http:// and if so, remove it.
Oops, just saw I made an error …
It’s supposed to be
if (document.getElementById("some_input_field").value.substring(0,7) == "http://")
{
document.getElementById("some_input_field").value = document.getElementById("some_input_field").value.substring(7);
}
Basically it checks if the first 7 characters form the character sequence http:// and if does, remove the first 7 characters from the input field. The first 7 characters are of course http:// so you remove that.