0

Using JavaScript, I am trying to set up a page redirect based on user input from a text box. When I fill out the text box, each if condition is met but the page is not redirecting.

<script type="text/javascript"> 
 
  function validateTextBox() { 
  
    var box = document.getElementById("width")
    var box2 = document.getElementById("height")
    var box3 = document.getElementById("length")
  
    if (box.value < 25 && box2.value < 25 && box3.value < 25) {
      window.location.href = "jointext.html";
    }                               
  }                                
</script>
     
</head>
    
<body>

<form id="theform" action="" method="post" onsubmit="validateTextBox()">
  <h3> What do I need </h3>
  <div class="row">
    <label for ="width"> Width Of Room in Metres </label> <br>
    <input type="text" id="width" name=""> <br><br>
  </div>

I have no idea why am I on the right lines?

I am fairly new in my learning so any advice would be great. Is this the way to go about this and if so what have I done wrong. Thanks all

Momin
  • 3,200
  • 3
  • 30
  • 48

1 Answers1

-1

Try using "onsubmit" instead of "onSubmit".

New Answer Try using action="URL" instead of action="" for redirection. If you wish to use it in function call remove action="".

Manas Gond
  • 640
  • 7
  • 13
  • that didnt work, i am not sure what is wrong ? can you think of anything else , thanks for help –  Jun 24 '20 at 23:02
  • HTML attribute names (and tag names) are de-facto case-insensitive, see https://stackoverflow.com/a/4351875/486382 – Sebastian B. Jun 25 '20 at 07:22