Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript window.location.href not working in localhost

I have a problem with my website. When there is "333" in the input box (id textbox_text) website is supposed to redirect to the specified url, but instead nothing happens. Where is the problem?

    <script>
            function IsEmpty()
            {
            if(document.forms['frm'].textbox_text.value == "333")
             {
                window.location.href="martyna-lesniak.html";
            }
            else 
            {
                alert("Nieprawidłowe hasło!");
            }
        }
    </script>
    <div class="container">
        <form name="frm">
            <input type="password" name="password1" class="password-input" id="textbox_text" placeholder="Wpisz hasło">
            <input type="submit" name="submit" onclick="return IsEmpty();" value="Wysyłaj" class="button-input" />
        </form>
    </div>
like image 468
Forcowicz Avatar asked Oct 15 '25 15:10

Forcowicz


1 Answers

You just have to return false; after your call to window.location.href="martyna-lesniak.html";.

like image 148
Digital Ninja Avatar answered Oct 17 '25 04:10

Digital Ninja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!