ASP Form Validation -- Submit Button

A

Arne Beruldsen

I have an app that is passing 3 lines (3 text boxes) via QueryString to an
ASP form. The User needs to complete the remaining 3 boxes (contact info
etc). I only want the validation to occur AFTER hitting the Submit
button...but when the ASP page loads it preforms the validation before the
user has had a chance to enter anything.

How can I make the validation occur only on hitting the Submit button?

Thanks...
 
J

Jon Spivey

Hi,
You'd need to wrap it in if then, eg
<%
if request.querystring <> "" then
' form has been submitted - validate it
end if
%>
 
A

Arne Beruldsen

I undersand the If / then...the problem is that is is validating Before the
submit button has been depressed. It's validating when the ASP page is
loaded. Apparently my if / then is in the wrong place...but where does it go?

Thanks
 
S

Stefan B Rusynko

You can't use server side scripting unless the form action is the page itself
Then if it validates redirect to the next page
(sending your good form field variables as session variables)
If it doesn't validate display an error and don't redirect

To avoid the error before a user has entered anything (initial page load)
Add a hidden form field to the form (or a session variable at end of page) and check for its presence first
- wrap the validation code inside of that check

Also use client side scripting to avoid a server round trip

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I undersand the If / then...the problem is that is is validating Before the
| submit button has been depressed. It's validating when the ASP page is
| loaded. Apparently my if / then is in the wrong place...but where does it go?
|
| Thanks
|
| "Jon Spivey" wrote:
|
| > Hi,
| > You'd need to wrap it in if then, eg
| > <%
| > if request.querystring <> "" then
| > ' form has been submitted - validate it
| > end if
| > %>
| >
| > --
| > Cheers,
| > Jon
| > Microsoft MVP
| >
| > | > >I have an app that is passing 3 lines (3 text boxes) via QueryString to an
| > > ASP form. The User needs to complete the remaining 3 boxes (contact info
| > > etc). I only want the validation to occur AFTER hitting the Submit
| > > button...but when the ASP page loads it preforms the validation before the
| > > user has had a chance to enter anything.
| > >
| > > How can I make the validation occur only on hitting the Submit button?
| > >
| > > Thanks...
| >
| >
| >
 
S

Stefan B Rusynko

You don't show it
You add it inside the form tags as
<input type="hidden" name="XYZ" value="ABC">
And the check for it as w/ any other field

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Good suggestion. How does one show a hidden form field?
|
| Thanks
|
| "Stefan B Rusynko" wrote:
|
| > You can't use server side scripting unless the form action is the page itself
| > Then if it validates redirect to the next page
| > (sending your good form field variables as session variables)
| > If it doesn't validate display an error and don't redirect
| >
| > To avoid the error before a user has entered anything (initial page load)
| > Add a hidden form field to the form (or a session variable at end of page) and check for its presence first
| > - wrap the validation code inside of that check
| >
| > Also use client side scripting to avoid a server round trip
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | > |I undersand the If / then...the problem is that is is validating Before the
| > | submit button has been depressed. It's validating when the ASP page is
| > | loaded. Apparently my if / then is in the wrong place...but where does it go?
| > |
| > | Thanks
| > |
| > | "Jon Spivey" wrote:
| > |
| > | > Hi,
| > | > You'd need to wrap it in if then, eg
| > | > <%
| > | > if request.querystring <> "" then
| > | > ' form has been submitted - validate it
| > | > end if
| > | > %>
| > | >
| > | > --
| > | > Cheers,
| > | > Jon
| > | > Microsoft MVP
| > | >
| > | > | > | > >I have an app that is passing 3 lines (3 text boxes) via QueryString to an
| > | > > ASP form. The User needs to complete the remaining 3 boxes (contact info
| > | > > etc). I only want the validation to occur AFTER hitting the Submit
| > | > > button...but when the ASP page loads it preforms the validation before the
| > | > > user has had a chance to enter anything.
| > | > >
| > | > > How can I make the validation occur only on hitting the Submit button?
| > | > >
| > | > > Thanks...
| > | >
| > | >
| > | >
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top