我的网站有问题。如果输入框(id textbox_text)中有“ 333”,则网站应重定向到指定的url,但是什么也没有发生。问题出在哪里?
<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>
您只需在致电return false;
后才需要window.location.href="martyna-lesniak.html";
。
如果您有需要在其他文件夹中引用的HTML,而您需要将实际的html放在资源的路径(html)中,那么另一件事是有条件的,您可以将===放在一个字面上相等的对象
尝试一下
<script>
function IsEmpty()
{
if(document.forms['frm'].textbox_text.value == "333")
{
window.location.href="martyna-lesniak.html";
return false;
}
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>