Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Validation controls validate before form submits (http://www.velocityreviews.com/forums/t776379-validation-controls-validate-before-form-submits.html)

TS 06-24-2005 06:29 PM

Validation controls validate before form submits
 
I have a page that spawns a new window. You select an item in it and it sets
a hidden input box on the parent page using javascript, then it submits the
parent and closes itself.

There are required field validators on the parent page. During this
javascript submit, the validation isn't occurring - which is good. The bad
part is that when the page comes back from the server, the validation
messages are now displayed. The user never had a chance to set the dropdowns
because they weren't visible until now.

Thinking about why its occurring made me wonder
1. why the validators don't validate when the popup window's javascript
submits the form (window.parent.form.submit()) .
2. why does the errors display only when the page is rendered and not when
the user clicks the submit button to submit the form?

thanks a bunch!



[MSFT] 06-27-2005 06:14 AM

RE: Validation controls validate before form submits
 
Hello,

The validation was done in the form's onsubmit event:

<FORM language=javascript id=Form1 name=Form1 onsubmit="if
(!ValidatorOnSubmit()) return false;" action=WebForm1.aspx method=post>

When you click a button on the form, this event was fired. If it was not
validated, the form won't be submited. However, when you submit it out of
the form with script, this event was fired but the form was still submited
even if it return false. This is why you got form submited and the
validation message still occur.

Luke





TS 06-27-2005 10:58 PM

Re: Validation controls validate before form submits
 
What can i do to make it so the form keeps posting like it does currently,
but the validation doesn't make it fail until after the popup is closed and
the user clicks submit button on parent form. Otherwise i have error
messages displayed without the user having a chance to populate them?

(I'll try to dynamically add these controls just after the popup window
closes and see if that will work)

thanks!

"[MSFT]" <lukezhan@online.microsoft.com> wrote in message
news:cdOKC%23teFHA.4856@TK2MSFTNGXA01.phx.gbl...
> Hello,
>
> The validation was done in the form's onsubmit event:
>
> <FORM language=javascript id=Form1 name=Form1 onsubmit="if
> (!ValidatorOnSubmit()) return false;" action=WebForm1.aspx method=post>
>
> When you click a button on the form, this event was fired. If it was not
> validated, the form won't be submited. However, when you submit it out of
> the form with script, this event was fired but the form was still submited
> even if it return false. This is why you got form submited and the
> validation message still occur.
>
> Luke
>
>
>
>




TS 06-27-2005 11:32 PM

Re: Validation controls validate before form submits
 
that didn't work.

I dont' know why it is validating. The control is created AFTER the form is
submitted - maybe the form already knows that validation failed, so it goes
ahead and shows all the error messages.

What can I do?

thanks

"TS" <manofsteele1@nospam.nospam> wrote in message
news:uRaXHv2eFHA.2740@TK2MSFTNGP10.phx.gbl...
> What can i do to make it so the form keeps posting like it does currently,
> but the validation doesn't make it fail until after the popup is closed

and
> the user clicks submit button on parent form. Otherwise i have error
> messages displayed without the user having a chance to populate them?
>
> (I'll try to dynamically add these controls just after the popup window
> closes and see if that will work)
>
> thanks!
>
> "[MSFT]" <lukezhan@online.microsoft.com> wrote in message
> news:cdOKC%23teFHA.4856@TK2MSFTNGXA01.phx.gbl...
> > Hello,
> >
> > The validation was done in the form's onsubmit event:
> >
> > <FORM language=javascript id=Form1 name=Form1 onsubmit="if
> > (!ValidatorOnSubmit()) return false;" action=WebForm1.aspx method=post>
> >
> > When you click a button on the form, this event was fired. If it was not
> > validated, the form won't be submited. However, when you submit it out

of
> > the form with script, this event was fired but the form was still

submited
> > even if it return false. This is why you got form submited and the
> > validation message still occur.
> >
> > Luke
> >
> >
> >
> >

>
>




[MSFT] 06-28-2005 03:00 AM

Re: Validation controls validate before form submits
 
Since you use the validation control, why do you need to submit the form
even the validation is not true? I think there is two work around here:

1. Set some default values in the controls so that the validation is true;
2. Don't use Validation control.

Luke


TS 06-28-2005 02:23 PM

Re: Validation controls validate before form submits
 
thanks

"[MSFT]" <lukezhan@online.microsoft.com> wrote in message
news:IxuSQ24eFHA.4300@TK2MSFTNGXA01.phx.gbl...
> Since you use the validation control, why do you need to submit the form
> even the validation is not true? I think there is two work around here:
>
> 1. Set some default values in the controls so that the validation is true;
> 2. Don't use Validation control.
>
> Luke
>





All times are GMT. The time now is 05:37 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.