这是我以前写的一段程序,上边有判断数据合法性,你可以参考以下:
<!--#include file="..\connection\conn.asp"-->
<!--#include file="..\link.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="common.css" rel="stylesheet" type="text/css">
</head>
<script language="VBScript" type="text/VBScript">
<!--
sub datacheck()
if form1.text1.value=Empty Then
msgbox "帐号不得为空",48,"请填全信息"
focusto(0)
exit sub
end if
if form1.text2.value =empty then
msgbox "姓名不得为空",48,"请填全信息"
focusto(1)
exit sub
end if
if form1.text4.value ="" then
msgbox "权限不得为空",48,"请填全信息"
focusto(4)
exit sub
end if
if form1.pd1.value ="" then
msgbox "密码不得为空",48,"请填全信息"
focusto(6)
exit sub
end if
if form1.pd2.value ="" then
msgbox "密码不得为空",48,"请填全信息"
focusto(7)
exit sub
end if
a=form1.pd1.value
b=form1.pd2.value
if (a<>b) then
msgbox "两次密码输入不一致",48,"两次输入的密码要一致"
focusto(7)
exit sub
end if
form1.submit ()
end sub
sub focusto(x)
document.form1.elements(x).focus()
end sub
-->
</script>
<body bgcolor="#E1E1E1" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<%
set rsd=Server.CreateObject("ADODB.Recordset")
sqld="select * from dianxinxi order by dh asc"
rsd.open sqld,conn,3,2
%>
<table width="100%" height="400" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="3" bgcolor="#FFFFFF"><img src="../images/spacer.gif" width="3" height="1"></td>
<td width="594" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="9"><img src="../images/spacer.gif" width="1" height="9"></td>
</tr>
<tr>
<td valign="top">
<table width="100%" height="391" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="70"> </td>
<td width="455" valign="top">
<table width="100%" height="391" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="31" align="center" background="../images/MB_st_bg.jpg" class="titlebig"><B>
员 工 信 息 添 加</b></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="center" class="label_blue"> </td>
</tr>
<tr>
<td valign="top">
建议不要使用随机数做编号,这样可能重复
建议用下面这个方法
Function GetNumber()
dim ranNum
ranNum=int(90000*rnd)+10000
GetNumber=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
End Function
判断合法可以用js,也可用vs
看你哪个语法习惯了
判断数据是否存在,可以在同一个页面也可以在不同也面,这个看个人习惯了
我建议你最好看看asp初级入门的书