469,277 Members | 2,405 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

What is wrong I want the form and the form validation in the same page

I have a simple form to accept two form fields and display the values
entered on pressing the submit button. The following is the form I have
created to accept the two entries and display the form fields on
pressing the submit form. It does not work can somebody please correct
the code or provide a simple equivalent code where I can have the form
and the validation and usage of the form values in the same ASP page.

Thanks
Karen

<html>
<body>
<form method="post">
From Period : <input type="text" name="FromPeriod">

<br>
To Period : <input type="text" name="ToPeriod">
<input type="submit" value="Submit" action = "Go">
</form>

<%
Dim FromVal, ToVal
FromVal = Request.Form("FromPeriod")
ToVal = Request.Form("ToPeriod")
Response.Write FromVal
Response.Write ToVal
If FromVal & ToVal <> ""
Then
Response.Write "Valid data entered"
End If
%>
</body>
</html>

Sep 30 '05 #1
4 1670
wrote on 30 sep 2005 in microsoft.public.inetserver.asp.general:
I have a simple form to accept two form fields and display the values
entered on pressing the submit button. The following is the form I have
created to accept the two entries and display the form fields on
pressing the submit form. It does not work can somebody please correct
the code or provide a simple equivalent code where I can have the form
and the validation and usage of the form values in the same ASP page.

Thanks
Karen

<html>
<body>
<form method="post">
From Period : <input type="text" name="FromPeriod"> <br>
To Period : <input type="text" name="ToPeriod">
<input type="submit" value="Submit" action = "Go">


Why action = "Go" ? Has no meaning, imho.
</form>

<%
Dim FromVal, ToVal
FromVal = Request.Form("FromPeriod")
ToVal = Request.Form("ToPeriod")
Response.Write FromVal
Response.Write FromVal & "<br>"
Response.Write ToVal
Response.Write ToVal & "<br>"

If FromVal & ToVal <> ""
Then
The Then must be on the same line as the If
Response.Write "Valid data entered"
End If
%>
</body>
</html>


with the Then corrected it works fine here,
except that

FromVal & ToVal <> ""

is true when "one of them is non empty.

I think you mean:

If (FromVal <> "") AND (ToVal <> "") Then

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 30 '05 #2
'// Begin pForm.asp
<html>
<body>
<form method="post" action="pForm.asp">
From Period : <input type="text" name="FromPeriod"><br>
To Period : <input type="text" name="ToPeriod">
<input type="submit" value="Submit" action = "Go">
</form>
<%
'// Check the first field only (assumes it is required)
If Request.Form("FromPeriod") <> "" Then
Response.Write "From: " & Request.Form("FromPeriod") & "<br>"
Response.Write "To: " & Request.Form("ToPeriod")
End If
%>
</body>
</html>

--
Regards

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

Keeping it FREE!

<ka***********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have a simple form to accept two form fields and display the values
entered on pressing the submit button. The following is the form I have
created to accept the two entries and display the form fields on
pressing the submit form. It does not work can somebody please correct
the code or provide a simple equivalent code where I can have the form
and the validation and usage of the form values in the same ASP page.

Thanks
Karen

<html>
<body>
<form method="post">
From Period : <input type="text" name="FromPeriod">

<br>
To Period : <input type="text" name="ToPeriod">
<input type="submit" value="Submit" action = "Go">
</form>

<%
Dim FromVal, ToVal
FromVal = Request.Form("FromPeriod")
ToVal = Request.Form("ToPeriod")
Response.Write FromVal
Response.Write ToVal
If FromVal & ToVal <> ""
Then
Response.Write "Valid data entered"
End If
%>
</body>
</html>

Sep 30 '05 #3
<ka***********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have a simple form to accept two form fields and display the values
entered on pressing the submit button. The following is the form I have
created to accept the two entries and display the form fields on
pressing the submit form. It does not work can somebody please correct
the code or provide a simple equivalent code where I can have the form
and the validation and usage of the form values in the same ASP page.

Thanks
Karen


[snip]

http://www.aspfaq.com/5003 !
Sep 30 '05 #4
HI Karen,

I don't think you can do what you want this way. You're trying to validate
data with server side scripting, which is run *before* the page is sent to
the browser. You need to use client side scripting (js or vb) to validate.

HTH
Martin
<ka***********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have a simple form to accept two form fields and display the values
entered on pressing the submit button. The following is the form I have
created to accept the two entries and display the form fields on
pressing the submit form. It does not work can somebody please correct
the code or provide a simple equivalent code where I can have the form
and the validation and usage of the form values in the same ASP page.

Thanks
Karen

<html>
<body>
<form method="post">
From Period : <input type="text" name="FromPeriod">

<br>
To Period : <input type="text" name="ToPeriod">
<input type="submit" value="Submit" action = "Go">
</form>

<%
Dim FromVal, ToVal
FromVal = Request.Form("FromPeriod")
ToVal = Request.Form("ToPeriod")
Response.Write FromVal
Response.Write ToVal
If FromVal & ToVal <> ""
Then
Response.Write "Valid data entered"
End If
%>
</body>
</html>

Sep 30 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by CJM | last post: by
reply views Thread by Miquel | last post: by
27 posts views Thread by Chris | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.