-3

I am creating a website and I am creating a form in it. In this form, I wanted to make it redirect to a URL (www.google.pt, for example) only if a keyword is written in the form when submitted (for example, "google"). Can anyone help me please? Here is the HTML code I've written to create the form:

<form action="/action_page.php" method="post">
  <input type="text">
  <br><br>
  <button type="submit">SUBMETER</button>
</form> 
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

1 Answers1

0
$(form).submit(function(e){
    e.preventDefault();
    if($(input).val().indexOf('yourWord') !== -1){
        window.location = 'http://www.google.pt';
    }
});
Cory Madden
  • 5,026
  • 24
  • 37