In many large forms, there are many possibilities for errors on the user's part. One thing that absolutely drives me nuts is to have filled out a huge form, receive an error, and have to re-enter all the data. For this reason, I don’t subject my users to the same problem. When I validate data, I will do it within the same ASP page, which means I can call the routine to show the form again. When I do this, I show all the input data as values within the form. Here's a one input box example:
<%
Call Main
Sub Main()
If Request("action") = "validate" Then
ValidateData
Else
ShowForm ""
End If
End Sub
Sub ShowForm(strError)
If strError <> "" Then
Response.Write "<font color=#FF0000" & strError & "</font>
" & vbCrLf
End If
Response.Write "<form action=""" & Request.ServerVariables("SCRIPT_NAME") _
& "?action=validate"">" & vbCrLf
Response.Write "<input type=text name=txtInput value=""" & Request("txtInput") & """>" & vbCrLf
Response.Write "<input type=submit name=cmdSubmit value=""Submit"">" & vbCrLf
End Sub
Sub ValidateData()
If Len(Request("txtInput")) < 5 Then
ShowForm "ERROR: Data must be at least 5 characters."
Response.End
Else
Response.Redirect "nextpage.asp"
End If
End Sub
%>
In this case, whatever the user put in the form will be redisplayed the second time the form is shown. This is a trivial example, but you can apply it to any size of form.