checkform.jsp
来自「用户登录管理」· JSP 代码 · 共 40 行
JSP
40 行
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>change</title>
</head>
<body>
<form name="test" method="post" action="index.jsp">
用户名:
<input type="text" name="UserName">
<br>
密码:
<input type="password" name="pwd">
<br>
<input type="button" value="提交" onClick="JavaScript:checkForm();">
</form>
</body>
</html>
<Script language="JavaScript">
function checkForm(){
//定义一个变量,引出表单对象
var theForm=document.TEST;
if(theForm.UserName.value=="")
{
alert("请输入用户名!");
theForm.UserName.focus();
}
else if(theForm.Pwd.value=="")
{
alert("请输入密码!");
theForm.Pwd.focus();
}else
{
theForm.submit();
}
}
</Script>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?