📄 sample6_1.jsp
字号:
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="com.ajaxlab.ajax.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Ch06--案例:数据校验</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function openFixWin(address, winname, height, width, scrollbars) {
var iHeight = height;
var iWidth = width;
var iLeft = (screen.width - iWidth)/2;
var iTop = (screen.height- iHeight)/2;
var iScrollbars = scrollbars;
if(iScrollbars == null || iScrollbars=="") iScrollbars = "no";
var feature = "left="+iLeft+",top="+iTop+",fullscreen=0,width= " + iWidth + ",height=" + iHeight +
",toolbar=no, menubar=no, scrollbars=" + iScrollbars + ", resizable=no, location=no, status=no"
var win =window.open(address,winname,feature);
return win;
}
function doCheck(type) {
var f = document.forms[0];
if("user"==type) {
if(f.username.value!="") openFixWin("registerCheck.jsp?field=username&value="+f.username.value,"唯一性检查",200,400,"no");
}
else if("email"==type) {
if(f.email.value!="") {
var pattern = /^[\w\.\-\_]+@{1}\w+(\.{1}\w+)+$/;
var result = pattern.exec(f.email.value);
if(result==null) window.alert("电子邮件格式错误,请按标准email名称格式填写,如:hello@sohu.com。");
else openFixWin("registerCheck.jsp?field=email&value="+f.email.value,"唯一性检查",200,400,"no");
}
}
}
</script>
</head>
<body><center>
<form name="form1" method="post" action="">
<table width="500" border="0" cellspacing="0" cellpadding="4">
<caption>用户注册</caption>
<tr>
<td width="70">用户名称:</td>
<td width="414"><input name="username" type="text" class="form_text" id="username" size="40">
<input name="userCheck" type="button" class="button" id="userCheck" value="唯一性检查" onClick="doCheck('user')">
</td>
</tr>
<tr>
<td>密码:</td>
<td><input name="password" type="password" class="form_text" id="password" size="40"></td>
</tr>
<tr>
<td>电子邮件:</td>
<td><input name="email" type="text" class="form_text" id="email" size="40">
<input name="emailCheck" type="button" class="button" id="emailCheck" value="唯一性检查" onClick="doCheck('email')">
</td>
</tr>
<tr align="center">
<td colspan="2"><input name="Submit" type="submit" class="button" value="提交"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -