主题:button的onclick属性中,如何写方法调用
<%@ page contentType="text/html;charset=utf-8" language="java" errorPage=""%>
<html>
<head>
<title>系统管理员注册</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script language="javascript">
function checkForm(form){
if(isEmpty(form.uid.value) || isEmpty(form.password.value) ||
isEmpty(form.confirmPassword.value) || isEmpty(form.email.value) ||
isEmpty(form.question.value) || isEmpty(form.answer.value)){
alert("请将必填项注册信息填写完整!");
return false;
}
if(form.password.value != form.confirmPassword.value){
alert("您输入的两次密码不匹配!");
return false;
}
if(form.password.value.length < 6 || form.password.value.length > 16){
alert("您输入的密码长度不得少于6个字符或多于16个字符!");
return false;
}
function isEmpty(str){
if(str == null || str.length == 0)
return true;
else
return false;
}
}
</script>
</head>
<body>
<form name = "userRegisterForm" method="post" action="/chenggong/register" onSubmit=checkForm(this)>
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="0">
<caption>
<font color="blue" style="font-size: 20px">系统管理员注册</font><br></caption>
<tr bgcolor="EFEFEF">
<td width="25%" align="right">管理员名称:</td>
<td width="30%" valign="bottom">
<input name="uid"type="text" id="uid" size="20" maxlength="50"></td>
<td width="45%">*
<input name="checkUser"type="button"value="查看是否被占用"
onclick="window.open('checkUid.jsp')">
</td>
</tr>
<tr bgcolor="#EFEFEF">
<td rowspan="1" colspan="5">(用户名由a~z的英文字母(不区分大小写),0~9的数字,点,减号或下划线组成,长度为3~18个字符,只能以数字或字母开头和结尾,例如:chenggong_0123)</td>
</tr>
<tr><td align="right" >密 码:</td>
<td><input name="password" type="password" id="password" size="20"
maxlength="50"></td>
<td>*(密码长度为6~16位,区分字母大小写.登陆密码可以由字母,数字,特殊字符组成.)</td>
</tr>
<tr bgcolor="#EFEFEF">
<td width="25%" height="40" align="right">密码确认:</td>
<td><input name="confirmPassword" type="password" id="confirmPassword" size="20" maxlength="50"></td>
<td>*(请再输入一遍,以便确认!)</td>
</tr>
<tr><td width="25%" height="40" align="right">电子邮件:</td>
<td><input name="email" type="text" size="20" maxlength="50"></td>
<td>*(请您输入正确的E-mail地址!<FONT color=#cc0000>方面您的密码查询</FONT>!)</td>
</tr>
<tr bgcolor="#EFEFEF"><td align="right">性 别:</td>
<td><p><label><input type="radio" name="gender" value="1" checked>男</label>
<label><input type="radio" name="gender" value="0" checked>女</label><br>
</p></td>
</tr>
<tr>
<td align="right" valign="middle"><div align="right"> 密码提示问题:</div></td>
<td><input name="question" type="text" size="20" maxlength="50"></td>
<td>*(帐号验证以及用于帮你找回密码!)</td>
</tr>
<tr bgcolor="#EFEFEF">
<td valign="middle"><div align="right">提示问题答案:</div></td>
<td><input name="answer" type="text" size="20" maxlength="50"></td>
<td bgcolor="#EFEFEF">*(找回密码的答案!)</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" name="Submit" value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>
上面代码中如何使"查看是否被占用"按钮能调用checkUid方法,谢谢指教!:)
<html>
<head>
<title>系统管理员注册</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script language="javascript">
function checkForm(form){
if(isEmpty(form.uid.value) || isEmpty(form.password.value) ||
isEmpty(form.confirmPassword.value) || isEmpty(form.email.value) ||
isEmpty(form.question.value) || isEmpty(form.answer.value)){
alert("请将必填项注册信息填写完整!");
return false;
}
if(form.password.value != form.confirmPassword.value){
alert("您输入的两次密码不匹配!");
return false;
}
if(form.password.value.length < 6 || form.password.value.length > 16){
alert("您输入的密码长度不得少于6个字符或多于16个字符!");
return false;
}
function isEmpty(str){
if(str == null || str.length == 0)
return true;
else
return false;
}
}
</script>
</head>
<body>
<form name = "userRegisterForm" method="post" action="/chenggong/register" onSubmit=checkForm(this)>
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="0">
<caption>
<font color="blue" style="font-size: 20px">系统管理员注册</font><br></caption>
<tr bgcolor="EFEFEF">
<td width="25%" align="right">管理员名称:</td>
<td width="30%" valign="bottom">
<input name="uid"type="text" id="uid" size="20" maxlength="50"></td>
<td width="45%">*
<input name="checkUser"type="button"value="查看是否被占用"
onclick="window.open('checkUid.jsp')">
</td>
</tr>
<tr bgcolor="#EFEFEF">
<td rowspan="1" colspan="5">(用户名由a~z的英文字母(不区分大小写),0~9的数字,点,减号或下划线组成,长度为3~18个字符,只能以数字或字母开头和结尾,例如:chenggong_0123)</td>
</tr>
<tr><td align="right" >密 码:</td>
<td><input name="password" type="password" id="password" size="20"
maxlength="50"></td>
<td>*(密码长度为6~16位,区分字母大小写.登陆密码可以由字母,数字,特殊字符组成.)</td>
</tr>
<tr bgcolor="#EFEFEF">
<td width="25%" height="40" align="right">密码确认:</td>
<td><input name="confirmPassword" type="password" id="confirmPassword" size="20" maxlength="50"></td>
<td>*(请再输入一遍,以便确认!)</td>
</tr>
<tr><td width="25%" height="40" align="right">电子邮件:</td>
<td><input name="email" type="text" size="20" maxlength="50"></td>
<td>*(请您输入正确的E-mail地址!<FONT color=#cc0000>方面您的密码查询</FONT>!)</td>
</tr>
<tr bgcolor="#EFEFEF"><td align="right">性 别:</td>
<td><p><label><input type="radio" name="gender" value="1" checked>男</label>
<label><input type="radio" name="gender" value="0" checked>女</label><br>
</p></td>
</tr>
<tr>
<td align="right" valign="middle"><div align="right"> 密码提示问题:</div></td>
<td><input name="question" type="text" size="20" maxlength="50"></td>
<td>*(帐号验证以及用于帮你找回密码!)</td>
</tr>
<tr bgcolor="#EFEFEF">
<td valign="middle"><div align="right">提示问题答案:</div></td>
<td><input name="answer" type="text" size="20" maxlength="50"></td>
<td bgcolor="#EFEFEF">*(找回密码的答案!)</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" name="Submit" value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>
上面代码中如何使"查看是否被占用"按钮能调用checkUid方法,谢谢指教!:)