Home All Groups Group Topic Archive Search About


Author
22 Feb 2005 1:50 PM
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.

Author
22 Feb 2005 2:03 PM
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!

Show quote
"middletree" <middlet***@htomail.com> wrote in message
news:e7bqwVOGFHA.2296@TK2MSFTNGP15.phx.gbl...
> 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.
>
>
Author
22 Feb 2005 2:13 PM
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!




Show quote
"Steven Burn" <somewhere@in-time.invalid> wrote in message
news:egWXtdOGFHA.128@TK2MSFTNGP14.phx.gbl...
> 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!
>
> "middletree" <middlet***@htomail.com> wrote in message
> news:e7bqwVOGFHA.2296@TK2MSFTNGP15.phx.gbl...
> > 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.
> >
> >
>
>
Author
22 Feb 2005 6:12 PM
Adrienne
Gazing into my crystal ball I observed "middletree"
<middlet***@htomail.com> writing in
news:#Q2T4iOGFHA.1396@tk2msftngp13.phx.gbl:

> 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.
Show quote
>
>
>
> "Steven Burn" <somewhere@in-time.invalid> wrote in message
> news:egWXtdOGFHA.128@TK2MSFTNGP14.phx.gbl...
>> 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!
>>
>> "middletree" <middlet***@htomail.com> wrote in message
>> news:e7bqwVOGFHA.2296@TK2MSFTNGP15.phx.gbl...
>> > 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.
>> >
>> >
>>
>>
>
>



--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

AddThis Social Bookmark Button

Post Other interesting topics