Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > What is wrong I want the form and the form validation in the same page

Reply
Thread Tools

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

 
 
karenmiddleol@yahoo.com
Guest
Posts: n/a
 
      09-30-2005
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>

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      09-30-2005
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)

 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      09-30-2005
'// 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!

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      09-30-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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 !


 
Reply With Quote
 
Martin Walke
Guest
Posts: n/a
 
      09-30-2005
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
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. Mark B ASP .Net 2 09-11-2009 07:09 AM
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. Dhruba Bandopadhyay ASP .Net 1 05-25-2006 01:06 AM
I want to create a link "e-mail this page to a friend" on clicking this link i want to send the URL of that current page to a friend pavi Javascript 0 01-13-2006 12:10 PM
Want to fill a form box2 automatically based on form box1 input [on the same page] Matt MC HTML 2 05-25-2005 10:07 PM
Want to fill a form box2 automatically based on form box1 input [on the same page] Matt MC Javascript 2 05-25-2005 10:07 PM



Advertisments