2

i have a form like this:

<form method="get" action="sample.php">
    <input type="text" name="url">
    <input type="submit" value="send">
</form>

when i sumbit form with an url(like https://google.com) my link is:

site.com/sample.php?url=https%3A%2F%2Fgoogle.com

but i want send Formed url like this (without https://):

site.com/sample.php?url=google.com

how i can do this?

Majid
  • 95
  • 2
  • 9

1 Answers1

0

Using jquery you can replace http:// or https:// with nothing before submit:

$("form").submit(function(){
   var $input = $(this).find("input[name=url]");
   var cleanValue = $input.val().replace("http://","").replace("https://","");
   $input.val(cleanValue);
});
rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82