473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1751
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
2
by: francisco lopez | last post by:
Yesterday I had a problem with a javascript to validate my form, but you helped my out yesterday and it works now perfectly!!! so thank you!!! the problem I have now is the following: I put...
0
by: Miquel | last post by:
Hi all. I felt frustrated when developing an 'UserControl' derivated from textBox, because sequence event (and Validate event) seems to fail. I Always thought my code was wrong. But after...
7
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving"...
9
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see)...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
1
by: JP2006 | last post by:
I am using asp.net input validation on a web form to check user input. The web form is on a web user control which is then dragged on to a ..aspx page. The .aspx page also contains other web user...
5
by: rockdale | last post by:
Hi, all: I have a website with its own login page. Now one of my clients want their employees log into my website from their website. They want to have their login page (look and feel are...
10
by: shapper | last post by:
Hello, I have a custom control under namespace MyNameSpace.WebControls with a property of type validation: ' Validation Private _Validation As Validation < _ Bindable(True), _...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.