Disable Validation when submitting via JScript?

J

Jo Inferis

For reasons that are unlikely to become clear at the moment, I have a page
with some validation controls on it which opens a dialog. The dialog does
*stuff* and then closes with a call to :

parent.document.forms[0].submit();

Unfortunately, this fires off all the validation controls on the page, and
I'd rather it didn't.

Any ideas how I can submit the form programmatically without firing the
validation events?

thanks in advance,
 
M

Marina

There is an onsubmit event handler that gets created. To disable it, try:

parent.document.forms[0].onsubmit = null

That should in theory get rid of that event handler.
 
J

Jo Inferis

Marina said:
parent.document.forms[0].onsubmit = null

That should in theory get rid of that event handler.

Hmm. Makes sense, but it doesn't work :(

My client side validation isn't running anyway, so that's not an issue. I
want to stop the server side validation from running as well...
 
M

Marina

This suggestion was to deal with client side validation. I don't think you
are going to stop server side validation from running unless you turn it off
on the server.

Jo Inferis said:
Marina said:
parent.document.forms[0].onsubmit = null

That should in theory get rid of that event handler.

Hmm. Makes sense, but it doesn't work :(

My client side validation isn't running anyway, so that's not an issue. I
want to stop the server side validation from running as well...
 
C

Craig Deelsnyder

For reasons that are unlikely to become clear at the moment, I have a
page
with some validation controls on it which opens a dialog. The dialog does
*stuff* and then closes with a call to :

parent.document.forms[0].submit();

Unfortunately, this fires off all the validation controls on the page,
and
I'd rather it didn't.

Any ideas how I can submit the form programmatically without firing the
validation events?

thanks in advance,

You can disable validators on the client-side via JS. If you look in the
web UI validation JS file, which is located somewhere like:

C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322

if you're using 1.1, there's a function in there called ValidatorEnable
that you can call to disable validators. I don't remember if there's a
'disable all' call you can make, or if you have to do one by one. Check
it out if interested....

Note doing it this way will not affect the Page.IsValid check from running
all active validators on the server side as well. Because the Enabled
property for each is in the viewstate and JS doesn't touch or affect that.
 
J

Jo Inferis

Marina said:
This suggestion was to deal with client side validation.
Yes, I figured that.
I don't
think you are going to stop server side validation from running
unless you turn it off on the server.
Why not?

Perhaps a hack would be to set up a button which has CausesValidation =
false and then programmatically click it. But I'm not sure this is actually
possible.
 
B

Bruce Barker

calling form.submit() does not fire the onsubmit event (which handles
validation). most likely, its the server side validation routines being
called.





Marina said:
There is an onsubmit event handler that gets created. To disable it, try:

parent.document.forms[0].onsubmit = null

That should in theory get rid of that event handler.

Jo Inferis said:
For reasons that are unlikely to become clear at the moment, I have a
page
with some validation controls on it which opens a dialog. The dialog does
*stuff* and then closes with a call to :

parent.document.forms[0].submit();

Unfortunately, this fires off all the validation controls on the page,
and
I'd rather it didn't.

Any ideas how I can submit the form programmatically without firing the
validation events?

thanks in advance,
 
M

Marina

Actually it should be. You should be able to call the button 'click' method
on the client.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top