Help! Client-side validation problem

Discussion in 'ASP .Net' started by Jim Brandley, Apr 2, 2004.

  1. Jim Brandley

    Jim Brandley Guest

    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.
    Jim Brandley, Apr 2, 2004
    #1
    1. Advertising

  2. Jim Brandley

    Peter Blum Guest

    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:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Jim Brandley" <> wrote in message
    news:...
    > 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.
    >
    >
    Peter Blum, Apr 4, 2004
    #2
    1. Advertising

  3. Jim Brandley

    Avinash Guest

    Not sure if you still need help.
    Try this link out;
    http://weblogs.asp.net/vga
    particularly Intercepting form submissions and
    Avoiding duplicated form submissions

    I hope this helps,
    Avinash
    Avinash, Apr 4, 2004
    #3
  4. Jim Brandley

    Jim Brandley Guest

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

    "Peter Blum" <> wrote in message
    news:...
    > 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:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Jim Brandley" <> wrote in message
    > news:...
    > > 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.
    > >
    > >

    >
    >
    Jim Brandley, Apr 5, 2004
    #4
  5. Jim Brandley

    Jim Brandley Guest

    Thanks - I've seen that one, but is doesn't solve my problem.

    "Avinash" <> wrote in message
    news:...
    > Not sure if you still need help.
    > Try this link out;
    > http://weblogs.asp.net/vga
    > particularly Intercepting form submissions and
    > Avoiding duplicated form submissions
    >
    > I hope this helps,
    > Avinash
    Jim Brandley, Apr 5, 2004
    #5
  6. Jim Brandley

    Jim Brandley Guest

    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.

    "Peter Blum" <> wrote in message
    news:...
    > 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:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Jim Brandley" <> wrote in message
    > news:...
    > > 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.
    > >
    > >

    >
    >
    Jim Brandley, Apr 5, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Libs
    Replies:
    0
    Views:
    1,482
  2. Matt
    Replies:
    14
    Views:
    4,070
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  3. =?Utf-8?B?dmlkeWE=?=
    Replies:
    1
    Views:
    740
    Kevin Spencer
    Jun 2, 2005
  4. Boss302
    Replies:
    0
    Views:
    1,018
    Boss302
    Nov 21, 2006
  5. Bogdan
    Replies:
    2
    Views:
    635
    Bogdan
    Jun 9, 2008
Loading...

Share This Page