<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>javascript学习例子</title>
<script language="javascript">
function submitClick(){
var userName=document.forms[0].userName.value;
if(userName==""){
alert("用户名不能为空");
return false;
}
var password=document.forms[0].password.value;
if(password==""){
alert("用户密码不能未空");
return false;
}
var rePassword=document.forms[0].rePassword.value;
if(rePassword==""){
alert("请重复输入密码");
return false;
}
if(password!=rePassword){
alert("两次输入密码不一致,请重新输入");
document.forms[0].password.value="";
document.forms[0].rePassword.value="";
document.forms[0].password.focus();
return false;
}
var feedBackInfo="";
feedBackInfo="你的用户名称为"+userName+ "你的密码为"+password;
document.forms[0].feedBackInfo.value=feedBackInfo;
alert(feedBackInfo);
}
function resetClick(){
document.forms[0].reset();
}
function callSubmitClick(){
document.forms[0].submit.click();
}
</script>
</head>
<body bgcolor="#009900" text="#FF0000" link="#FFFFFF">
<form action="" method="post" name="inputForm" target="_blank">
<br>请输入用户名称:<input name="userName" type="text" id="userNameId"/>
<br>请输入用户密码:<input name="password" type="password" id="password"/>
<br>请重复输入用户密码:<input name="rePassword" type="password" />
<br>用户输入信息反馈:<input name="feedBackInfo" type="text" size="60" readonly />
<br>
<input name="submit" type="button" value="提交" οnclick="javascript:submitClick();"/>
<input name="rewrite" type="button" value="重写" οnclick="javascript:resetClick();" />
<br><input name="transfer" type="button" value="调用提交按钮" οnclick="callSubmitClick();" />
</form>
</body>
</html>