ASP程序设计教程 MsgBox"密码应该在6到12位之间。 f txt= then MsgBox"确认密码不能为空 Forml grmm Focus it Sub 工ftxt5<xtxt6Then MsgBOx"密码和确认密码不相同! Forml grmm Focus Exit Sub 工ftxt3=""then MsgBox"电话不能为空!" Forml dh. Focus Exit su If not isNumeric( txt2)Then MsgBOx"请输入数字! If (Instr("@",txt7)=0 and Instr(".", txt)=o)then MsgBOx"请输入有效的emai1地址!" Exit sub a11txt="姓名为:"+txt1+vbcr1f a11txt=a1ltxt+"年龄为:"+txt5+vbcr1f a11txt=a11txt+"年龄为:"+txt2+vber1f 11txt=a11txt+"电话为:"+txt3+vbcr1f a11txt=a11txt+"住址为:"+txt4 intb= MsgBOx(a11txt,4+32,"确认提交") If intb=6 Then Forml submit End工f End sul Sub but tonl onkeypress If WindowsEvent. KeyCode=l3 then
16 ASP 程序设计教程 MsgBox "密码应该在 6 到 12 位之间。" Form1.mm.Focus Exit Sub End If If txt6="" then MsgBox "确认密码不能为空!" Form1.qrmm.Focus Exit Sub End If If txt5<>txt6 Then MsgBox "密码和确认密码不相同!" Form1.qrmm.Focus Exit Sub End If If txt3="" then MsgBox "电话不能为空!" Form1.dh.Focus Exit Sub End If If not isNumeric(txt2) Then MsgBox "请输入数字!" Form1.nl.Focus Exit Sub End If If (InStr("@",txt7)=0 and InStr(".",txt7)=0) then MsgBox "请输入有效的 email 地址!" Form1.email.Focus Exit Sub End If alltxt="姓名为:"+txt1+vbcrlf alltxt=alltxt+"年龄为:"+txt5+vbcrlf alltxt=alltxt+"年龄为:"+txt2+vbcrlf alltxt=alltxt+"电话为:"+txt3+vbcrlf alltxt=alltxt+"住址为:"+txt4 intb=MsgBox(alltxt,4+32,"确认提交") If intb=6 Then Form1.submit End If End Sub Sub button1_onkeypress If Windows.Event.KeyCode=13 then button1_onclick End If End Sub --> </Script>
对象 </HEAD> <FORM id=Forml me thod="post" action="zhuceasp"> <p>姓名:< INPUT id= xm name=xm></p><bx> <p>密码:< INPUT type=" password"id= TIm name=m> 确认密码:< INPUT type=" password"id= gLuon nane=qrm></p><br> <p>年龄:< INPUT id=n1name=n1> 电话:< INPUT id= dh name=dhx</p><br> <p>住址:< INPUT id= zz name=zz> email: <INPUT id=email name=email></p><br> <INPUT id=buttonl name=button type=button value="ex"> <INPUT id=button2 name=button2 type=reset value="t"> </LEFT> FORM> </BODY> </HTML 例3-8-1 <HTML> <HEAD <TITE>文档加载错误</ TITLE <Script Language="VBScript"> Dim intvar, intResult, strvar intvar=120 strvar=Tom" 在进行计算时类型不匹配 intResult=intvar*strvar MsgBOx("结果为:"& intRest1t) </script> <BODY> /BODY> </HTML> 例3-8-2: <HTML> < TITLE>网页运行错误</ TITLE> <Script Language="VBScript"> Sub config()
第 4 章 Response 与 Request 对象 17 </HEAD> <BODY bgcolor=White> <FORM id=Form1 method="post" action="zhuce.asp"> <LEFT> <p>姓名:<INPUT id=xm name=xm></p><br> <p>密码:<INPUT type="password" id=mm name=mm> 确认密码:<INPUT type="password" id=qrmm name=qrmm></p><br> <p>年龄:<INPUT id=nl name=nl> 电话:<INPUT id=dh name=dh></p><br> <p>住址:<INPUT id=zz name=zz> email:<INPUT id=email name=email></p><br> <INPUT id=button1 name=button1 type=button value="提交"> <INPUT id=button2 name=button2 type=reset value="重填"> </LEFT> </FORM> </BODY> </HTML> 例 3-8-1: <HTML> <HEAD> <TITLE>文档加载错误</TITLE> <Script Language="VBScript"> <!-- Dim intVar,intResult,strVar intVar=120 strVar="Tom" ’在进行计算时类型不匹配 intResult=intVar*strVar MsgBox("结果为:"&intResult) --> </Script> </HEAD> <BODY> ... </BODY> </HTML> 例 3-8-2: <HTML> <HEAD> <TITLE>网页运行错误</TITLE> <Script Language="VBScript"> <!-- Sub config()
ASP程序设计教程 MsgBOx("你好! d Sub btn1 onFocus Window. status="欢迎光临! End sub Sub btn1 OnB lur Window. status="欢迎下次再来! ′将对象的名字拼写错误 Windows. close End sub </Script> </HEAD> <BODY> INPUT type=" button"name="btn1”va1ue="点击" onClick=" config()"> </HT 第4章 Response与 Request对象 例4-2-1 <i@ LANGUAGE="VBScript" Response Buffer=True 8> <号 Response. Buffer=Fa1se影> <HTML> <HEAD> < TITLE>使用缓冲示例</TILE> <TE>不使用缓冲示例</T工TLE> </HEAD> </HEAD> <BODY> <BODY> firsttime=timer firsttime=timer ri=1To5000 Response. Write"i的值为 Response. Write"i的值为 (4) if i mod 4=0 then Response. Write if i mod 4=0 then Response. Write <br> Next Next second ime=timer jg=secondtime-firsttime jg=secondtime-firsttime Response, write"用时:"&jg&"秒 Response. write"用时:"&jg&”秒 </HTML> TTMI
18 ASP 程序设计教程 MsgBox("你好!") End Sub Sub btn1_OnFocus Window.status="欢迎光临!" End Sub Sub btn1_OnBlur Window.status="欢迎下次再来!" ’将对象的名字拼写错误 Windows.close End Sub --> </Script> </HEAD> <BODY> <INPUT type="button" name="btn1" value="点击" onClick="config()"> </BODY> </HTML> 第 4 章 Response 与 Request 对象 例 4-2-1: <%@ LANGUAGE="VBScript" %> <% Response.Buffer=True %> <HTML> <HEAD> <TITLE>使用缓冲示例</TITLE> </HEAD> <BODY> <% firsttime=Timer For i = 1 To 5000 Response.Write "i 的 值 为 : "&i&space(4) if i mod 4=0 then Response.Write "<br>" Next secondtime=Timer jg=secondtime-firsttime Response.write "用时:"&jg&" 秒" %> </BODY> </HTML> <%@ LANGUAGE="VBScript" %> <% Response.Buffer=False %> <HTML> <HEAD> <TITLE>不使用缓冲示例</TITLE> </HEAD> <BODY> <% firsttime=Timer For i = 1 To 5000 Response.Write "i 的 值 为 : "&i&space(4) if i mod 4=0 then Response.Write "<br>" Next secondtime=Timer jg=secondtime-firsttime Response.write "用时:"&jg&" 秒" %> </BODY> </HTML>
对象 例4-2-2 输出字符串 Response. Write"这是一个字符串." 输出HTML标记 Response. Write 输出字符和HTML标记 Response. Write"<p>< font co1or='red>这是一个红色的字符串</ font></p> Response. Write"<p>欢迎访问<a http://www.myhomecomcn'>我的网页 输出数字、字符和HTML标记 Response. Write "The sum is.#& 1+2 &<BR> 输出变量的值 a="这是一个字符串." b="< font color='red">这是一个红色的字符串</font> Response. Writea&b&"<BR>结束! 例4-2-3: Response. Write"同学们好!"&"<BR> 显示带引号的字符串 Response. Write"""&”同学们好!""""&",他说到," Response. Write""&"服务器脚本以·号\>结束 例424: <BODY> 获取系统当前时间 dtmHour Hour (Now()) 判断是否为上午 If dtmHour >=8 and dtmHour < 18 Then Response. Redirect " work.h Else Response. Redirect rest. htm" </BODY>
第 4 章 Response 与 Request 对象 19 例 4-2-2: <% '输出字符串 Response.Write "这是一个字符串. " '输出 HTML 标记 Response.Write "<BR>" '输出字符和 HTML 标记 Response.Write "<p><font color='red'>这是一个红色的字符串</font></p>" Response.Write "<p> 欢迎访问<a href='http://www.myhome.com.cn'> 我的网页 </a></p>" '输出数字、字符和 HTML 标记 Response.Write "The sum is. " & 1+2 & "<BR>" '输出变量的值 a="这是一个字符串. " b="<font color='red'>这是一个红色的字符串</font>" Response.Write a & b & "<BR>结束!" %> 例 4-2-3: <% '显示字符串 Response.Write " 同学们好! "&"<BR>" '显示带引号的字符串 Response.Write """"&" 同学们好! "&""""&",他说到," '显示"%>" Response.Write """"&"服务器脚本以'%\>'结束 "&""""&"<BR>" %> 例 4-2-4: <% Response.Buffer=True %> <HTML> <BODY> <% '获取系统当前时间 dtmHour = Hour(Now()) '判断是否为上午 If dtmHour >= 8 and dtmHour <= 18 Then Response.Redirect "work.htm" Else Response.Redirect "rest.htm" End If %> </BODY>
ASP程序设计教程 </HTML>
20 ASP 程序设计教程 </HTML>