function validate()
{
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if ( username==null || username=="" && password==null || password=="");
{
alert("Please enter username and password");
return false;
}
else ( username == "james1" && password == "j1j22j3j" )
{
alert ("Login successfully");
window.location = "http://www.dtrekrun.com/training.html"; // Redirecting to other page.
return false;
}
}
我尝试验证用户名/密码并显示提醒。但它不适合我。
答案 0 :(得分:0)
你没有在控制台中看到任何错误吗?
删除此行末尾的分号:
if ( username==null || username=="" && password==null || password=="");
否则不要参数,否则就是这样!替换
else ( username == "james1" && password == "j1j22j3j" )
通过
else if ( username == "james1" && password == "j1j22j3j" )
答案 1 :(得分:0)
使用此
if ( username==null || username=="" && password==null || password=="")
而不是
if ( username==null || username=="" && password==null || password=="");
和
else ( username == "james1" && password == "j1j22j3j" )
通过
else if ( username == "james1" && password == "j1j22j3j" )
希望你获得成功
答案 2 :(得分:0)
在if之后删除分号(username == null || username ==“”&& password == null || password ==“”);