-2

I've some form like this:

<form action="#" method="post">
    <input type="text" name="website" />
</form>

How I can find if user enter website with http:// or without? I want to show it in:

<a href="value from input">

Any suggestions how to validate this form and send it to database as right link like: http://website...?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
pusty
  • 45
  • 7
  • Sorry, I really have no idea what you're asking – freefaller May 12 '15 at 09:06
  • Because you want to work with database I would say take a look at :http://stackoverflow.com/questions/4366730/check-if-string-contains-specific-words . Than use `php echo` to echo what you want in your `` tag – Vinc199789 May 12 '15 at 09:10

1 Answers1

0

You may use javascript to validate input.

function validate()
{
  var input = document.getElementsByName("website")[0].value;
  if(input.startsWith("http://")) {
      alert("valid input");
      return true;
  }
 
  alert("invalid input");
  return false;
    
}
<form action="#" method="post" onsubmit="return validate()">
    <input type="text" name="website" />
    <input type="submit" />
</form>
niyasc
  • 4,440
  • 1
  • 23
  • 50