gpt4 book ai didi

ios - 在 Cordova 中使用 Button 进行登录验证后重定向

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:53:01 27 4
gpt4 key购买 nike

我是 Cordova 语言的初学者。我正在尝试在 javascript 中单击按钮时重定向我的 html 页面。在 validateform 方法中,我想重定向到我的主页。我已经尝试了所有可能的事情,例如 window.location, document.location 。但我没有得到重定向的确切答案。

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
window.onload = function()
{
document.addEventListener("deviceready", init, false);
}

function init()
{
var myButton = document.getElementById("BtnClick");
myButton.addEventListener("click", validateform, false);
}

function validateform()
{
var myButton = document.getElementById("BtnClick");
var user = document.getElementById("username").value;
var paswd = document.getElementById("password").value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

if (user == "") {
alert("Name must be filled out");
return false;
} else if (reg.test(user) == false) {
alert("Invalid Email Address");
return false;
} else if (paswd == "") {
alert("Password must be filled out");
return false;
} else {
alert("TRY!");
document.location = "home.html";
return false;
}
}
</script>

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
</head>

<body>
<form id="loginForm" class = "centered" >
<div class="middle">
<img src = "img/newlogo.png" width="150" height="150"/>
</div>

<div data-role="fieldcontain">
<input type="email" name="username" id="username" value="tst@test.com" placeholder="Username" class="middle textfield"/>
</div>

<div data-role="fieldcontain" >
<input type="password" name="password" id="password" value="789456" placeholder="Password" class="middle textfield" maxlength="10"/>
</div>

<div class = "middle">
<button id = "BtnClick" class = "button" >Submit</button>
</div>
</form>
</body>
</html>

最佳答案

感谢大家的帮助!我找到了解决方案:

index.html

<div class = "loginButton">
<a id = "BtnClick">Submit</a>
</div>

validateform方法中:

window.location.href = "home.html";

关于ios - 在 Cordova 中使用 Button 进行登录验证后重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52420959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com