form1.html
来自「用于编些网站的Javascript」· HTML 代码 · 共 67 行
HTML
67 行
<html>
<head>
<style type="text/css">
span{
color : red;
margin-left : 6px;
}
</style>
<script language="javascript">
function testEve(tag){
alert("run");
tag.value = "";
}
function testSub(){
//获得两个password的值
var pass1 = document.getElementById("pass1").value;
var pass2 = document.getElementById("pass2").value;
if(pass1 == pass2){
return true;
}else{
alert("two passwords must be same");
return false;
}
}
function check(tag){
//判断value是否为空
if( !tag.value || tag.value == ""){
tag.nextSibling.firstChild.data = "this text can not be null !";
//判断value长度是否小于7
}else if(tag.value.length < 7){
tag.nextSibling.firstChild.data = "length must larger than 7 !";
}else{
tag.nextSibling.firstChild.data = "*";
}
}
</script>
</head>
<body>
<!--
<input type="text" onblur="testEve(this)">
<input value="onchange test" onchange="testEve()">
-->
<form action="#" method="GET" onsubmit="return testSub()">
<table border="0" cellspacing="0" align="center" width="70%">
<tr>
<td width="15%">User Name:</td>
<td><input type="text" name="name" onblur="check(this)"><span>*</span></td>
</tr>
<tr>
<td>Password :</td>
<td><input id="pass1" type="password" name="pass" onblur="check(this)"><span>*</span></td>
</tr>
<tr>
<td>Pass again :</td>
<td><input id="pass2" type="password" name="pass" onblur="check(this)"><span>*</span></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?