|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Validation controls validate before form submitsI 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! 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 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! Show quoteHide quote "[MSFT]" <lukez***@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 > > > > 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 Show quoteHide quote "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]" <lukez***@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 > > > > > > > > > > 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 thanks
Show quoteHide quote "[MSFT]" <lukez***@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 >
HtmlInputFile issue
check if image or file exists asp 2.0 wizard control (how to set focus on button) Implicit conversion from one object to another Easy way to use bound combo with foreignkey id/value on webform? set focus List'o MyProj CSS Elements? DataGrid edit mode how to insert text into middle of textarea DropDownList_SelectedIndexChanged event not being fired?? |
|||||||||||||||||||||||