Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Validation

Status
Not open for further replies.

arundahar

Programmer
Apr 27, 2001
53
GB
Hi, i have a large form of data. I think the best way to check this form is to submit the page to another "handling" page. The form has over 20 fields on it. Do i have to go through each field saying:
If Len(strUsername) = 0 then
response.redirect "previous_page?errorcode="
end If

..for each of the 20 fields, as well as checking that passwords match. I've tried using For each Item in Request.Form but it returns them in a strange order and doesn't handle checkboxes easily. Any ideas anyone?

Also is there any better way of displaying an error message to user other than using the Querystring? I CANNOT use Javascript for any checking!!!

Also how will i store extra info that is present on the first page if i have to redirect? How do i set a global that doesn't change but can be passed from page to page? I CANNOT use any SESSION variables either!

Thanks

A
 
what can you use? I'm confused on why you cannot use Session variables, help me understand provide tools to let people become their best.
 
arundahar,

You would probably be better off by doing client-side validation. This allows the browser to check if all the fields are entered before it gets submitted to the server.

fengshui_1998


<body>
<form name=&quot;myform&quot; method=&quot;post&quot; action=&quot;myanswers.asp&quot;>
<input type=&quot;text&quot; name=&quot;username&quot; size=20>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; onclick=&quot;return checkform()&quot;>
</form>

</body>

<script language=&quot;javascript&quot;>
function checkform() {
if (document.myform.username.value.length == 0)
{ alert(&quot;Please input your username.&quot;);
return false; }
else
return true;
}
</script>

</html>

 
arundahar,

Sorry,

I missed your note about NOT using javascript. I guess you'll have to try more vbscript.

fengshui_1998
 

perhaps you could try putting some of your variables into hidden fields?

<input type=&quot;hidden&quot; name=&quot;name&quot; value=&quot;<%= myVariable %>&quot;>

Andy
 
yes but no hidden fields will work with a redirect. All form information will be lost won't it!?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top