我有一个按钮,当您单击它时,它将启动一个函数,该函数的目的是查看一堆语句是否为真,如果是,则应将我发送到另一页
<a href="">
<button value="Registar" id="btn_registar" type="button" class="btn btn-default text-center" style="width: 90px; height: 30px; border-radius: 4px; cursor: pointer;" onclick="validar()">
<b>Registar</b></button>
</a> <p id="reg_off></p>
我的功能:
function validar(){
var nome = document.getElementById("nome").value;
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var conf_password = document.getElementById("conf_password").value;
//var idade = .... FALTA O CALCULO DA IDADE
if(nome == "" || username == "" || password == "" || conf_password == "")
{
//alert("NOT WORKING");
document.getElementById("reg_off").innerHTML = "ups";
//WHEN I USE THE BUTTON ON THIS CONDITIONS, THE MESSAGE APPEARS BUT IT ONLY SHOWS FOR LIKE A MICROSECOND
} else {
alert("WORKED");
window.location.href = "area_reservada.php";
}
}
答案 0 :(得分:-1)
将其更改为
window.location.href = "area_reservada.php";
应该帮助
(但这会将URL设置为area_reservada.php
),因此您需要在其中插入完整的URL