Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2004, 03:51 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default Validation of Page

Hi,

I'd like to know how to validate a form. When the form is submitted and there are errors in the form fields, i'd like to see the same form again, but with the wrong field turned red and empty, and the proper filled field should contain their data. this should all happen on the same page.
Thanks


Love 4 all
__________________
(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is  how you got it
Reply With Quote
  #2 (permalink)  
Old June 21st, 2004, 05:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

You can use something like this to achieve that.

Code:
<%
Dim testVal, TestValErrMsg

If Request.form("Submit")<>"" then
    testVal=Request.form("testVal")
    If len(trim(testVal))=0 then
        TestValErrMsg = "Cannot be Empty String.Please re-enter the value"
    Else
     ''' Process the value, may be store that in db and then,
     ''' Redirect to another page, that says, the values are stored.
     ''' or say that values are processed in the same page at the top
     ''' and clean up the values of all the form variables, without redirecting to another page.
     End If
End If
%>

...
...
...

<Form action="" method="post">
    <input type="text" name="testVal" value="<%=testVal%>">
<%
    If len(trim(TestValErrMsg))>0 then Response.write TestValErrMsg
%>
    <input type="Submit" name="Submit" value="Submit">
</Form>
Hope that helps.
Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old June 21st, 2004, 06:03 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

I have a lot of information on that page and if there is error then User finds an error message but the information loss how I can save that information

Love 4 all
Reply With Quote
  #4 (permalink)  
Old June 21st, 2004, 06:18 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Unfortunately, there is no way to automatically post the value to the form back, I think.

Please go through my reply for the issue "Different objects send in links" which you started on 18th June. I am quoting it here again. for your easiness.
--------------------------------------------------------------------------------------------------

A change in the page structure is needed.

You have a registration page which checks the details of the visitor submitted through a page say - registration.asp. Let that page be registrationFB.asp. i.e. registration.asp collects the visitor details initially and submits to registrationFB.asp

You have a page which will be shown after successful registration. Let that page be welcome.asp

The form on registrationFB.asp should submit to the same page. The code structure in registrationFB.asp is as follows.

' Collect the posted values from registration.asp in variables

' The validation script

' Initialize a variable strErrorMessage as an empty string. (strErrorMessage="")

' check whether fields are empty.

' check whether login exists.

' after each validation check you need to concatenate the error message to the variable strErrorMessage.

' if(strErrorMessage="") then

' show the error message

' show the form. In the form show the values. You can get the values from the variables into which you stored them at the beginning of the page. Please remember that this form gets submitted to registrationFb.asp.

' else

' go to welcome.asp

' end if
----------------------------------------------------------------------------------------------
Reply With Quote
  #5 (permalink)  
Old June 21st, 2004, 06:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Madhukp,

Quote:
quote:Unfortunately, there is no way to automatically post the value to the form back, I think.
I am not sure what does automatically post the value to the form back mean here?

Quote:
quote:You have a registration page which checks the details of the visitor submitted through a page say - registration.asp. Let that page be registrationFB.asp. i.e. registration.asp collects the visitor details initially and submits to registrationFB.asp

You have a page which will be shown after successful registration. Let that page be welcome.asp

The form on registrationFB.asp should submit to the same page. The code structure in registrationFB.asp is as follows.
I don't understand why one should have registration.asp and registrationFB.asp, for this?

I assume both the pages are going to have the form with similar fields in them. Why should the structure that you suggest on registrationFB.asp be not written on registration.asp itself?

Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
  #6 (permalink)  
Old June 21st, 2004, 06:50 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Dears I have a page Registration.asp and Confirm.asp and on confirm.asp if any type of error then I wil redirect to Registration.asp.
I want to know when it wil redirect then where it stores the information

Love 4 all
Reply With Quote
  #7 (permalink)  
Old June 21st, 2004, 07:06 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I mean, without writing any code, there is no way to get back the previously typed values. In ASP.Net, there is a way to retrieve posted values incase there is some error.

Yes, you can post the form to the same page and have the same form. But since the form is big and it involves lot of variables (to temporarily save the posted values), it will make the pages lengthy. (I hate long pages !!)

gazi_nomi,

If you are using same page for showing form as well as validating and storing into db, you need to initialize all the variables which will be used to store the posted values.
Reply With Quote
  #8 (permalink)  
Old June 21st, 2004, 07:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

qazi_nomi,

Quote:
quote:I have a page Registration.asp and Confirm.asp and on confirm.asp if any type of error then I wil redirect to Registration.asp. I want to know when it wil redirect then where it stores the information
That way it is not easy to achieve what you posted in your original post.

If you got to show errors in RED for fields that do not conform to your validation rules and should also show the values in its form controls besides the ERROR in red, then you cannot check for error in your confirm.asp.

To achieve that, you got the post the values to registration.asp in which you can check for the values and assign error message for relevant fields that do not conform to the validation rules and show them besides the relevant fields on the same page. If everything is fine then you can store them into DB if you want, and redirect to confirm.asp, where you say, data has been stored successfully.

That is probably what I have posted in my first reply to this post.

Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
  #9 (permalink)  
Old June 21st, 2004, 07:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Madhukp,

But I feel the way of using 2 such pages (with similar form fields in them) is going to pose you problem in maintaining them and I am sure, one would have to code more than what it can be done in one such page.

Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
  #10 (permalink)  
Old June 22nd, 2004, 12:34 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

I have two pages for that one is for registraton and one is for its confirmation.
If there is any error occured in confirmation page then all information of registration
page wil be lost.
It is only problem and one solution which is in my mind that I think in javascript there is a method for sending page back but i dont know how to use that
If any one knows then guide me PLZ

Love 4 all
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Javascript validation not working in content page Manoj Bisht ASP.NET 2.0 Basics 0 March 3rd, 2008 02:21 AM
Validation using Validation Framework kalyangvd Struts 1 January 2nd, 2008 06:53 AM
Form Validation and Redirect Page jourys ASP.NET 1.0 and 1.1 Basics 1 February 24th, 2006 12:20 PM



All times are GMT -4. The time now is 11:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.