Help! Client-side validation problem

J

Jim Brandley

I have a required field with a client-side validator. It works as advertised
until I try to add code to block double submits and replace the image on
the submit button to give the users some feedback. I have localized the
problem to the definition of the form.onSubmit handler.

Without my blocker, it looks like:
onsubmit="ValidatorOnSubmit();"

Since my javascript to block the double submit and change the image should
only run if client-side validation passes, I have to insert the
ValidatorOnSubmit call before my script is invoked, then dot net adds it
again at the end. So, it looks like:

onsubmit="if (FormSubmitted == true){return
false;};ValidatorOnSubmit();BlockDoubleSubmit(SubmitButtonID);ValidatorOnSub
mit();"

Looks like it should work, but now the client-side validation does not take
place at all. I am out of ideas. Is there another way to get a script
function invoked only if the client-side validation passes?

Any help would be much appreciated.
 
P

Peter Blum

Hi Jim,

If you are disabling the submit button in your BlockDoubleSubmit() function,
it is occuring before the form submits. The disabled button will not submit
the page. You have to delay disabling this button until after the form
submission occurs.

Please see this thread for a detailed discussion on this issue.
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=500836

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
J

Jim Brandley

I'm not really disabling the button. It just changes "FormSubmitted" to
true, and changes the decoration on the button.
 
J

Jim Brandley

I just found it. The problem was allowing ValidatorOnSubmit to run twice.
After reading through WebUIValidation.js, I changed it to the following:

if (FormSubmitted == true)

{return false;};

ValidatorOnSubmit();

if (event.returnValue)

{BlockDoubleSubmit(SubmitButtonID);return true;}

else {return false;};



Now it works great.
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top