24便利店有避孕套吗:各位大侠帮帮忙asp表单验证的问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 11:56:53
代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
<!--
body {
background-color: #9999CC;
}
input {
background-color: #D5D5EA;
}
textarea {
background-color: #D5D5EA;
}
table {
font-size: 12px;
text-decoration: none;
border: thin dashed #8484C1;
}
td {
font-size: 12px;
border: thin dotted #8484C1;
text-align: left;
}
-->
</style></head>
<center>
<body>
用户注册<br>
<form name="form1" method="post" action="">
<table width="39%" height="105" border="0" >
<tr>
<td width="27%">用户名:</td>
<td width="73%"><input name="user" type="text" id="user">
*</td>
</tr>
<tr>
<td>密码:</td>
<td><input name="pwd" type="password" id="pwd">
*</td>
</tr>
<tr>
<td>确定密码:</td>
<td><input name="pwd2" type="password" id="pwd2">
*</td>
</tr>
<tr>
<td>性别:</td>
<td>男
<input type="radio" name="sex" value="radiobutton">

<input type="radio" name="sex" value="radiobutton"></td>
</tr>
<tr>
<td>QQ:</td>
<td><input name="qq" type="text" id="qq"></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="mail" type="text" id="mail"></td>
</tr>
<tr>
<td>提示问题:</td>
<td><input name="quest" type="text" id="quest"> </td>
</tr>
<tr>
<td>答案:</td>
<td><input name="getpassword" type="text" id="getpassword"> </td>
</tr>
<tr>
<td>地址:</td>
<td><input name="add" type="text" id="add"></td>
</tr>
<tr>
<td>个人介绍</td>
<td><textarea name="pinf" cols="30" rows="6" id="pinf"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</center>
</html>
加了验证之后的效果是如果必填项出现错误则在其右边显示提示语句

<SCRIPT language=javascript>
function Show(id)
{
id.style.display="";
}
function Hide(id)
{
id.style.display="none";
}

function Check()
{
if (user.value=="")
{
user.focus();
Show(user_text);
}
}
</script>

<td width="27%">用户名:</td>
<td width="73%"><input name="user" type="text" id="user" onblur="Hide(user_text)">
*<span id="user_text" style="display:none">请输入用户名</span></td>

这样当用户名为空的时候就会在用户名右边出现提示了,其他项可同样按这种方式添加提示(还可添加多项提示按条件显示)。