Products
GG网络技术分享 2025-03-18 16:14 1
<%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"gb2312\"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+\"://\"+request.getServerName()+\":\"+request.getServerPort()+path+\"/\";
%>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<base href=\"<%=basePath%>\">
<title>京东商城新用户注册</title>
<style type=\"text/css\">
.label{
position:absolute;
right:70%;
}
.fi{
position:relative;
left:30%;
}
.clr{
height:20px;
color:AAAAAA;
font-size:12px;
visibility:hidden;
}
.s{
font-weight:lighter;
color:red;
}
.text{
font-family:宋体;
width:200px;
}
.v{
color:cccccc;
font-size:12px;
}
a{
font-size:12px;
}
.btn-img{
position:relative;
left:30%;
}
.ok{
background:url(\"image\\gou_meitu_1.jpg\");
width:17px;
height:16px;
visibility:hidden;
display:none;
}
#strength{
color:AAAAAA;
font-size:12px;
display:none;
}
.showStren{
width:135px;
display:inline;
color:white;
font-size:12px;
}
.ceil{
border:0.5px solid #FFFFFF;
background-color:DDDDDD;
}
</style>
<script type=\"text/javascript\">
function inUser(){
username_mess.style.visibility=\"visible\";
}
function outUser(){
u=f1.username.value;
f1.username.style.border=\"1px solid AAAAAA\";
if(u==\"\"){
username_mess.style.visibility=\"hidden\";
return;
}
reg= /.{4,20}/; //代表着允许4到20位字符,用两个/表示定义表达式,这样reg就有test方法了,返回值是true和false,另外还有exec方法,返回值是null,意味着不匹配,以及字符串,意味着匹配上了什么字符串
if(!reg.test(u)){
username_mess.innerHTML=\"用户名长度只能在4-20位字符之间\";
username_mess.style.color=\"red\";
f1.username.style.color=\"red\";
f1.username.style.border=\"1px solid red\"
username_ok.style.visibility=\"hidden\";
return;
}
reg= /^[\\u4e00-\\u9fa5 \\w-]{4,20}$/; //代表着中文字符和\\w(\\w能够代替[a-zA-Z0-9_])还有-
if(reg.test(u)){
username_ok.style.visibility=\"visible\";
username_mess.innerHTML=\"\";
f1.username.style.color=\"black\";
}else{
username_mess.innerHTML=\"用户名只能由中文、英文、数字及\"_\"、\"-\"组成\";
username_mess.style.color=\"red\";
f1.username.style.color=\"red\";
f1.username.style.border=\"1px solid red\";
username_ok.style.visibility=\"hidden\";
}
}
function inPass(){
pass_mess.style.visibility=\"visible\";
f1.pwd.style.border=\"1px solid gold\";
}
function outPass(){
p=f1.pwd.value;
f1.pwd.style.border=\"1px solid AAAAAA\";
if(p==\"\"){
pass_mess.style.visibility=\"hidden\";
return;
}
}
function inRPass(){
rpass_mess.style.visibility=\"visible\";
f1.pwd2.style.border=\"1px solid gold\";
}
function outRPass(){
p=f1.pwd2.value;
f1.pwd2.style.border=\"1px solid AAAAAA\";
if(p==\"\"){
rpass_mess.style.visibility=\"hidden\";
return;
}
if(!(f1.pwd.value==f1.pwd2.value)){
rpass_mess.innerHTML=\"两次输入的密码不一致\";
rpass_mess.style.color=\"red\";
f1.pwd2.style.color=\"red\";
f1.pwd2.style.border=\"1px solid red\";
repass_ok.style.visibility=\"hidden\";
return;
}
}
function visibe(){
if(f1.visi.checked){ //通过checked属性,能够得到这个复选框是否被选中的Boolean值
pass.style.backgroundColor=\"FFEEEE\";
v=f1.pwd.value;
v2=f1.pwd2.value;
chang.innerHTML= \"<input type=\'text\' name=\'pwd\' class=\'text\' tabindex=\'2\' value=\'\"+v+\"\' onFocus=\'inPass()\' onBlur=\'outPass()\'/>\";
chang2.innerHTML=\"<input type=\'text\' name=\'pwd2\' class=\'text\' tabindex=\'2\' value=\'\"+v2+\"\' onFocus=\'inRPass()\' onBlur=\'outRPass()\'/>\";
}else{
pass.style.backgroundColor=\"FFFFFF\";
v=f1.pwd.value;
v2=f1.pwd2.value;
chang.innerHTML=\"<input type=\'password\' name=\'pwd\' class=\'text\' tabindex=\'2\' value=\'\"+v+\"\' onFocus=\'inPass()\' onBlur=\'outPass()\'/>\";
chang2.innerHTML= \"<input type=\'password\' name=\'pwd2\' class=\'text\' tabindex=\'2\' value=\'\"+v2+\"\' onFocus=\'inRPass()\' onBlur=\'outRPass()\'/>\";
}
}
function keyPass(){
if(f1.pwd.value.length>=6){
pass_mess.style.display=\"none\";
strength.style.display=\"inline\";
sum=checkStrong(f1.pwd.value);
if(sum==1){
l.style.backgroundColor=\"orange\";
}
if(sum==2){
l.style.backgroundColor=\"orange\";
m.style.backgroundColor=\"orange\";
}
if(sum==3){
l.style.backgroundColor=\"orange\";
m.style.backgroundColor=\"orange\";
h.style.backgroundColor=\"orange\";
}
}
}
function checkStrong(Str){
sum=0;
reg= /[a-zA-Z]/;
if(reg.test(Str)){
sum++;
}
reg= /\\d/;
if(reg.test(Str)){
sum++;
}
reg= /[_-]/;
if(reg.test(Str)){
sum++;
}
return sum;
}
function inMail(){
mail_mess.style.visibility=\"visible\";
f1.mail.style.border=\"1px solid gold\";
}
function outMail(){
mm=f1.mail.value;
f1.mail.style.border=\"1px solid AAAAAA\";
if(mm==\"\"){
mail_mess.style.visibility=\"hidden\";
return;
}
reg=/\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*/;
if(reg.test(mm)){
mail_ok.style.visibility=\"visible\";
mail_mess.innerHTML=\"\";
f1.mail.style.color=\"black\";
}else{
mail_mess.innerHTML=\"邮箱格式不正确\";
f1.mail.style.color=\"red\";
f1.mail.style.color=\"red\";
f1.mail.style.border=\"1px solid red\";
mail_ok.style.visibility=\"hidden\";
}
}
</script>
<meta http-equiv=\"pragma\" content=\"no-cache\">
<meta http-equiv=\"cache-control\" content=\"no-cache\">
<meta http-equiv=\"expires\" content=\"0\">
<meta http-equiv=\"keywords\" content=\"keyword1,keyword2,keyword3\">
<meta http-equiv=\"description\" content=\"This is my page\">
<!--
<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">
-->
</head>
<!--我们用div显示提示信息的时候,有两种常用的方法,一是事先写好预设的信息到div,将其设置为隐藏,当事件发生的时候,将相应的信息设置成可见。 -->
<!--第二种方式使直接用innerHTML写信息到div中 -->
<body>
<form id=\"f1\">
<div class=\"label\"><b class=\"s\">*</b>用户名:</div>
<div class=\"fi\">
<input type=\"text\" name=\"username\" class=\"text\" tabindex=\"1\" onFocus=\"inUser()\" onBlur=\"outUser()\"/> <!--动作:光标进入输入框的事件是onFocus,离开输入框的事件是onBlur -->
<label id=\"username_ok\" class=\"ok\"></label><br/> <!--label标签不会再新的一行显示 -->
<div id=\"username_mess\" class=\"clr\">4-20位字符,可由中文、英文、数字及\"_\"、\"-\"组成</div> <!--事先写好预设的信息到div -->
</div>
<div id=\"pass\">
<div class=\"label\"><b class=\"s\">*</b>设置密码:</div>
<div class=\"fi\">
<div id=\"chang\" style=\"display:inline\">
<input type=\"password\" name=\"pwd\" class=\"text\" tabindex=\"2\" onFocus=\"inPass()\" onBlur=\"outPass()\" onKeyup=\"keyPass()\"/>
</div>
<input type=\"checkbox\" name=\"visi\" id=\"viewpwd\" onClick=\"visibe()\"/>
<label id=\"pass_ok\" class=\"ok\"></label>
<label class=\"v\">显示密码字符</label><br/>
<div id=\"strength\">安全强度:
<table class=\"showStren\" align=\"center\">
<tr align=\"center\">
<td id=\"l\" class=\"ceil\">弱</td>
<td id=\"m\" class=\"ceil\">中</td>
<td id=\"h\" class=\"ceil\">强</td>
</tr>
</table>
</div>
<div id=\"pass_mess\" class=\"clr\">6-16位字符,可由英文、数字及\"_\"、\"-\"组成</div>
</div>
<div class=\"label\"><b class=\"s\">*</b>确认密码:</div>
<div class=\"fi\">
<div id=\"chang2\">
<input type=\"password\" name=\"pwd2\" class=\"text\" tabindex=\"3\" onFocus=\"inRPass()\" onBlur=\"outRPass()\"/>
</div>
<label id=\"rpass_ok\" class=\"ok\"></label><br/>
<div id=\"rpass_mess\" class=\"clr\">请再次输入密码</div>
</div>
</div>
<div class=\"label\"><b class=\"s\">*</b>邮箱:</div>
<div class=\"fi\">
<input type=\"text\" name=\"mail\" class=\"text\" tabindex=\"4\" onFocus=\"inMail()\" onBlur=\"outMail()\"/>
<label id=\"mail_ok\" class=\"ok\"></label>
<label class=\"v\">免费邮箱:</label>
<a href=\"\">搜狐</a>
<a href=\"\">网易</a><br/>
<div id=\"mail_mess\" class=\"clr\">请输入常用的邮箱,将用来找回密码、接收订单通知等</div>
</div>
<div class=\"label\"><b class=\"s\">*</b>推荐人用户名:</div>
<div class=\"fi\">
<input type=\"text\" name=\"referrer\" class=\"text\" value=\"可不填\" tabindex=\"5\"/><br/><div class=\"clr\"></div>
</div>
<input type=\"button\" name=\"pwd2\" class=\"btn-img\" id=\"registsubmit\" value=\"同意一下协议,提交\" tabindex=\"8\"/>
</form>
</body>
</html>
你这个正则明显写的有问题:reg= /.{4,20}/;
应该是 reg= /^.{4,20}$/;
LABjs 的核心是 LAB(Loading and Blocking):Loading 指异步并行加载,Blocking 是指同步等待执行。LABjs 通过优雅的语法(script 和 wait)实现了这两大特性,核心价值是性能优化。LABjs 是一个文件加载器。
RequireJS 和 SeaJS 则是模块加载器,倡导的是一种模块化开发理念,核心价值是让 JavaScript 的模块化开发变得更简单自然。
模块加载器一般可降级为文件加载器用,因此使用 RequireJS 和 SeaJS,也可以达成 LABjs 的性能优化目的。
RequireJS 和 SeaJS 都是很不错的模块加载器,两者区别如下:
1. 两者定位有差异。RequireJS 想成为浏览器端的模块加载器,同时也想成为 Rhino / Node 等环境的模块加载器。SeaJS 则专注于 Web 浏览器端,同时通过 Node 扩展的方式可以很方便跑在 Node 服务器端
2. 两者遵循的标准有差异。RequireJS 遵循的是 AMD(异步模块定义)规范,SeaJS 遵循的是 CMD (通用模块定义)规范。规范的不同,导致了两者 API 的不同。SeaJS 更简洁优雅,更贴近 CommonJS Modules/1.1 和 Node Modules 规范。
3. 两者社区理念有差异。RequireJS 在尝试让第三方类库修改自身来支持 RequireJS,目前只有少数社区采纳。SeaJS 不强推,而采用自主封装的方式来“海纳百川”,目前已有较成熟的封装策略。
4. 两者代码质量有差异。RequireJS 是没有明显的 bug,SeaJS 是明显没有 bug。
5. 两者对调试等的支持有差异。SeaJS 通过插件,可以实现 Fiddler 中自动映射的功能,还可以实现自动 combo 等功能,非常方便便捷。RequireJS 无这方面的支持。
6. 两者的插件机制有差异。RequireJS 采取的是在源码中预留接口的形式,源码中留有为插件而写的代码。SeaJS 采取的插件机制则与 Node 的方式一致:开放自身,让插件开发者可直接访问或修改,从而非常灵活,可以实现各种类型的插件。
还有不少细节差异就不多说了。
总之,SeaJS 从 API 到实现,都比 RequireJS 更简洁优雅。如果说 RequireJS 是 Prototype 类库的话,则 SeaJS 是 jQuery 类库。
最后,向 RequireJS 致敬!RequireJS 和 SeaJS 是好兄弟,一起努力推广模块化开发思想,这才是最重要的。
玉伯
Demand feedback