function showPopUp() {
var isConfirmed = confirm("Are you sure you want to logout ?");
if (isConfirmed) {
window.location = "./logout";
}
};
function isEmpty(){
console.log("isEmpty");
};
@CHARSET "ISO-8859-1";
form {
margin:0 auto;
width:300px
}
input {
margin-bottom:3px;
padding:10px;
width: 100%;
border:1px solid #CCC
}
button {
padding:10px
}
label {
cursor:pointer
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="/MyProject/js/customJavaScript.js"></script>
<link href="/MyProject/css/LoginRegister.css" rel="stylesheet"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>
<form id='login-form' action="./login" method='POST'>
<label></label>
<input onkeyup="isEmpty()" type="text" name="userName" placeholder="Username" required>
<input onkeyup="isEmpty()" type="password" name="password" placeholder="Password" required>
<button type='submit'>Login</button>
<label><a href="./register">Register</span></label>
</form>
</body>
</html>
带有两个函数的js文件。 文件:
function showPopUp() {
var isConfirmed = confirm("Are you sure you want to logout ?");
if (isConfirmed) {
window.location = "./logout";
}
}
function isEmpty(){
console.log("isEmpty");
}
我正在jsp中导入文件:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<c:url value='/js/customJavaScript.js'/>"></script>
<link href="<c:url value="/"/>css/LoginRegister.css" rel="stylesheet"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>
<form id='login-form' action="./login" method='POST'>
<label>${errorMsg}</label>
<input onkeyup=showPopUp() type="text" name="userName" placeholder="Username" required>
<input onkeyup=isEmpty() type="password" name="password" placeholder="Password" required>
<button type='submit'>Login</button>
<label><a href="./register">Register</span></label>
</form>
<c:remove var="errorMsg" scope="session"/></body></html>
当使用shopPupUp函数激活输入上的onkeyup时,它正常工作,确认显示并且没问题。
但是当我使用isEmpty函数激活输入上的onkeyup时,我在控制台中收到以下错误:
未捕获的ReferenceError:未定义isEmpty 在HTMLInputElement.onkeyup
有人有什么想法吗?
答案 0 :(得分:0)
Chrome 中的Ctrl + Shift + Del
组合。选中“缓存的图像和文件”复选框,然后单击“清除浏览数据”修复此问题。