几个入门级小问题,麻烦大家告诉我。

Shiyl 2004-01-13 10:19:35
1、ASP网页里如何生成随机数作为编号传递?
2、文本框中怎么判断输入合法性?是否要另外写函数?
2、我现在把判断数据合法性的过程写在同一个ASP文件中,这里并不是和数据库相连进行判断只是判断是否为空以及输入是否合法,如何按下按钮,或者窗体提交时调用这个文件?
...全文
36 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Shiyl 2004-01-14
  • 打赏
  • 举报
回复
up
bwboy 2004-01-13
  • 打赏
  • 举报
回复
include进来就可以了。
shleo 2004-01-13
  • 打赏
  • 举报
回复
不重复的随即编号一样可以实现,
不过需要建一个数组
Shiyl 2004-01-13
  • 打赏
  • 举报
回复
谢谢楼上的各位,我知道了<input type="button" name="button1" value="添加"

onClick="datacheck">这段代码的作用是按下“添加”后调用datacheck这个过程,现在我有个问题,如果我把datacheck写在另一个ASP文件里,文件名比如是CHECK.ASP,怎么调用?
谢谢!
hshore 2004-01-13
  • 打赏
  • 举报
回复
这是我以前写的一段程序,上边有判断数据合法性,你可以参考以下:
<!--#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">

<form name="form1" method="post" action="addchuli.asp">
<table width="64%" border="0" align="center" >
<tr>
<td width="42%" class="label" align="right">
<strong>员工帐号</strong>   </td>
<td width="58%"><input type="text" name="text1" height="15" size="15"></td>
</tr>
<tr>
<td class="label" align="right"> <strong>员工姓名</strong>  </td>
<td><input type="text" name="text2" height="15" size="15"></td>
</tr>
<tr>
<td class="label" align="right"><strong>员工性别 </strong>  </td>
<td><select name="select1" size="1">
<option value="男">男</option>
<option value="女">女</option>
</select></td>
</tr>
<tr>
<td class="label" align="right"><strong>所属店名</strong>  </td>
<td><select name="text3">
<% do while not rsd.eof %>
<option value=<%= trim(rsd(0))%>>
<%=rsd(1) %></option>
<%
rsd.movenext
loop
%>
</select> </td>
</tr>
<tr>
<td class="label" align="right"><strong>员工权限</strong>  </td>
<td><select name="text4">
<option value="0">系统管理员</option>
<option value="1">经理</option>
<option value="2">总库管</option>
<option value="6">连锁店长</option>
<option value="3">连锁店</option>
<option value="4">分店维修</option>
<option value="5">其他人员</option>
</select> </td>
</tr>
<tr>
<td class="label" align="right"><strong>员工职位</strong>
 </td>
<td><input type="text" name="text5" height="15" size="15"></td>
</tr>
<tr>
<td class="label" align="right"><strong>员工密码</strong>  </td>
<td><input type="password" name="pd1" height="15" size="15"></td>
</tr>
<tr>
<td class="label" align="right"><strong>确认密码  </strong></td>
<td><input type="password" name="pd2" height="15" size="15"></td>
</tr>
<tr>
<td class="label" align="right"><strong>联系方式 </strong> </td>
<td><input type="text" name="text6" height="15" size="15"></td>
</tr>
<tr>
<td height="23" colspan="3">           
         
<div align="center">
<input type="button" name="button1" value="添加" onClick="datacheck">
<input name="重填" type="reset">
</div></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="69"> </td>
</tr>
</table></td>
</tr>
</table>
</td>
<td width="3" bgcolor="#FFFFFF"><img src="../images/spacer.gif" width="3" height="1"></td>
<td> </td>
</tr>
</table>

<%
rsd.close
set rsd=nothing
conn.close
set conn=nothing
%>
</body>
</html>
cuipi2003 2004-01-13
  • 打赏
  • 举报
回复
建议不要使用随机数做编号,这样可能重复
建议用下面这个方法
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初级入门的书
bingofei 2004-01-13
  • 打赏
  • 举报
回复
1、给你一段随机显示图像的例子
< % dim p,ppic,dpic
ppic=12
randomize
p=Int((ppic*rnd)+1)
dpic="graphix/randompics/"&p&".gif"
% >

2、确实要另外写函数。

3、窗体提交是客户端事件,可以用javascript或者vbscript来完成。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧