server-side validation

M

middletree

I posted this yesterday afternoon, but for some reason, I don't see it in my
newsreader, on either of my 2 computers. So I am re-posting.


I'd like to see if there is any guidance in the form of sample code or a
tutorial for server-side validation. Specifically for the thing I am trying
to do, if a user types too many letters into Textarea, then they see an
error on the screen. I was able to catch most occurrences of this error with
client-side javascript. However, I'd like to handle it server-side in order
to catch those cases that get by the javascript for whatever reason. If I
could just catch the error before it gets displayed, then display a warning
in red letters in a pretty format, then that's all I'm hoping to do.

I went to ASPFAQ.com, didn't find anything there. I also did a search of
this forum and didn't see anything. I know conceptually what I want to do,
but I am not sure how to go about it.
 
S

Steven Burn

sTemp = Request.Form("txtaSomeTextArea")
If Len(sTemp) > 1000 Then
Response.Redirect "/?err=1&tmp=" & sTemp
End If

'// Example form
<%
If Request.Querystring("err") <> "" Then Response.Write "Error: Too many
characters<br><br>"
%>
<form action="thispage.asp" name="frmTemp">
<textarea name="txtaSomeTextArea"><%if len(request.querystring("tmp") > 0
Then%><%=request.querystring("tmp")%><%end if%></textarea>
<input type="submit" name="btnSubmit">
</form>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
M

middletree

OK, this is a good answer. It comes from a completely different direction
from what I was thinking. I was thinking I'd have to come up with code which
read the SQL Server error after it had been generated and displayed my
customer message instead of the SQL/ASP error. Your solution captures the
problem before it gets that far. I like this. I see where it will take some
work to capture all the other parts of the form and put them back into
place, but it will be worth doing.

thanks very much!
 
S

Steven Burn

I was never one for complicating things (brain farts excluded of course
<g>)...

.... and your welcome ;o)

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
A

Adrienne

OK, this is a good answer. It comes from a completely different
direction from what I was thinking. I was thinking I'd have to come up
with code which read the SQL Server error after it had been generated
and displayed my customer message instead of the SQL/ASP error. Your
solution captures the problem before it gets that far. I like this. I
see where it will take some work to capture all the other parts of the
form and put them back into place, but it will be worth doing.

thanks very much!

You might like some of the stuff at
http://www.intraproducts.com/beta/requiredform.asp , does some other server
side validation and has a good way to display errors to the client.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top