经典ASP中文本框中的值 [英] Value in textbox in Classic ASP

查看:66
本文介绍了经典ASP中文本框中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表单,它们是几个文本框,
单击提交按钮后,我想要的是什么,无论文本框中的值是什么,都不会消失,因为我将验证放在其上,因为再次单击提交,即使值是正确的,我也必须输入值.
因此,我希望无论输入什么值都应该固定不变,并且只有在验证为false时才更改.

我的代码是:

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<BODY>
<form method="post" action="page2.asp">
<p>Firstname              <INPUT name="fname"></p>
<p>LastName             <INPUT name="lname"></p>
<p>Address              
  
<INPUT name="add" ></p>
<p>Contact Number   <INPUT name="contactnum"></p>
<p>Date Of Birth      <INPUT name="dob" 
        style="margin-left: 10px" ></p>
<p><INPUT name="submit" value="submit" type=submit></p></FORM>
</BODY>
</HTML>

<%
Dim textfname,textlname,add,contact,dob,msg,count
msg=""
count=0
Function RefererIs(pagename)
IF Right(Request.ServerVariables("HTTP_REFERER"),len(pagename)) = pagename Then
		RefererIs = True
	Else
		RefererIs = false
	End IF
	Select case RefererIs
	case false 
	select case instr(lcase(request.servervariables("HTTP_REFERER")),Lcase(pagename)) 
		case 0 
		case else
			RefererIs =True
	    End Select
	    Case Else
	    End Select
End Function
IF RefererIs("page2.asp") Then
textfname= Request("fname")
textlname=Request("lname")
add=Request("add")
contact=Request("contactnum")
dob=Request("dob")
		IF Request("submit")="submit" THEN
			IF Trim(textfname)="" THEN
			msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Please Enter Your First Name</font>"
			count=count+1
			End If
			IF Trim(textlname)="" THEN
			msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Please Enter Your Last Name</font>"
			count=count+1
			End If
			IF Trim(add)="" THEN
			msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Please Enter Your Address</font>"
			count=count+1
			End If
			IF Trim(contact)="" THEN
			msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Please Enter Your Contact Number</font>"
			count=count+1
			Else
						IF IsNumeric(contact)="False" THEN
						msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Contact Should be Numeric</font>"
						count=count+1
						End If		
			End If
			IF Trim(dob)="" THEN
			msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Please Enter Your Date of Birth</font>"
			count=count+1
			Else 
						IF IsDate(dob)="False" THEN
						msg=msg+"<br><font size="" 2="" face="" verdana="" color="" red="">Please Enter Your Date of Birth In Correct Format</font>"
						count=count+1
						End If
			End If
								
			IF count>0 THEN
			Response.Write(msg)
			ELSE
			Response.Redirect("page1.asp?fname="& textfname & "&lname="& textlname & "&add="& add & "&contactnum="& contact & "&dob="& dob)
			END IF
		END IF
END IF
%></br></br></br></br></br></br></br>



[edit]忽略HTML ..."选项已禁用-OriginalGriff [/edit]

解决方案

由于您正在重定向并传递查询字符串,因此您可能需要在加载页面时获取值. [
解决方案

Since you are doing a redirect and passing your query strings, you might want to get the values when you load the page. This[^] article can probably help.


这篇关于经典ASP中文本框中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆