Click here to Skip to main content
15,921,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a form and their are several textbox,
What i want that after click on submit button, whatever the valueis in textbox dont disappear, as I put validation over their as i Click submit again i have to put the value even though value is correct.
So, i want Whatever value i entered should be fixed not changed, and it acn only changed when validation is false.

my code is:
<%@ 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]"Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 24-Jul-11 21:43pm
v3
Comments
Member 7697835 14-Jun-13 1:12am    
I have to Upload image and get the textbox values in the same time. But both are not working in the same time. request.form("textboxName") is not working while uploading a image.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900