Hello,
Below please find a very simple code: form (form1) checks if two fields (T1
and T2) have entries and then submits to another page (confirmation.asp) As
you can see validation is done on the client side.
How do I change this code below so that validation be done on the server side?
Since I am a new to JavaScript programming, could you please do all the
changes necessary.
Thank you.


<html>
<head>
<script>
function DoSubmit()
{
if (document.form1.T1.value=="")
{
window.alert("Please fill the field No. 1 ")
return false
}
if (document.form1.T2.value=="")
{
window.alert("Please fill the field No. 2")
return false
}
document.form1.target="_self"
document.form1.action="confirmation.asp"
document.form1.submit()
}



</script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Submit</title>
</head>

<body>

<form method="POST" action="--WEBBOT-SELF--" name="form1">
<!--webbot bot="SaveResults" U-File="_private/form_results.csv"
S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p><input type="text" name="T1" size="20"></p>
<p><input type="text" name="T2" size="20"></p>
<p> </p>
<span style="cursor:hand" onclick="DoSubmit()">Submit</span>
</form>

</body>
</html>

Re: From client to server validation by MD

MD
Thu Jul 21 07:46:18 CDT 2005

Hi Alec,

You'd have to change the type of page to ASP then there are two possible methods for doing the validation. For example.

<%
dim t1, t2, errMsg

errMsg = ""

t1 = request.form("T!")
if len(t1) = 0 then
errMsg = "Please enter a value for T1<br>"
end if
t2 = request.form("T2")
if len(t2) = 0 then
errMsg = errMsg = "Please enter a value for T2<br>"
end if

if len(errMsg) = 0 then
response.redirect "nextpage.asp"
end if

<html>

...

<body>
<% if len(errMsg) > 0 then response.write errMsg %>
.....

<form action="thispage.asp" ..... >
....
</form>

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


"alec" <alec@discussions.microsoft.com> wrote in message news:2FD2D72B-7348-47CA-82D5-8B75C990C4B8@microsoft.com...
> Hello,
> Below please find a very simple code: form (form1) checks if two fields (T1
> and T2) have entries and then submits to another page (confirmation.asp) As
> you can see validation is done on the client side.
> How do I change this code below so that validation be done on the server side?
> Since I am a new to JavaScript programming, could you please do all the
> changes necessary.
> Thank you.
>
>
> <html>
> <head>
> <script>
> function DoSubmit()
> {
> if (document.form1.T1.value=="")
> {
> window.alert("Please fill the field No. 1 ")
> return false
> }
> if (document.form1.T2.value=="")
> {
> window.alert("Please fill the field No. 2")
> return false
> }
> document.form1.target="_self"
> document.form1.action="confirmation.asp"
> document.form1.submit()
> }
>
>
>
> </script>
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title>Submit</title>
> </head>
>
> <body>
>
> <form method="POST" action="--WEBBOT-SELF--" name="form1">
> <!--webbot bot="SaveResults" U-File="_private/form_results.csv"
> S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
> <p><input type="text" name="T1" size="20"></p>
> <p><input type="text" name="T2" size="20"></p>
> <p> </p>
> <span style="cursor:hand" onclick="DoSubmit()">Submit</span>
> </form>
>
> </body>
> </html>