ASPNet validation and Javascript

Discussion in 'ASP .Net' started by Dick W, Jul 1, 2004.

  1. Dick W

    Dick W Guest

    I have a page that conatins some text boxes that need to be completed
    before submission. I used requiredFieldValidators which work very
    well.

    User being what they are where quite happy, but they wanted an
    Hourglass displayed when the page is submitted as they can't remember
    whether they have clicked the button.

    I found the following javascipt and vb souce that wires the submit
    button to a client side javascript that displays the hourgalss and
    submits the form, but this ignores the validation controls.

    I've reverted to using server side validation to re-display the form
    if the boxes are not completed, but this is far from ideal

    Anyone any idea on how I can display an hourglass AND use the client
    side validation controls, or suggest an alternative.

    Form contains a submit button btnSubmit

    Pageload code behind file:
    btnSubmit.Attributes.Add("onClick", "return doit();")

    javascript:

    <script language="javascript">
    function doit()
    {
    document.body.style.cursor='wait'
    }
    </script>

    btnsubmit on-click code executes as normal after hourglass displayed

    Thanks
    Dick W, Jul 1, 2004
    #1
    1. Advertising

  2. Dick W

    Hans Kesting Guest

    "Dick W" <> wrote in message news:...
    > I have a page that conatins some text boxes that need to be completed
    > before submission. I used requiredFieldValidators which work very
    > well.
    >

    [snip]
    > Form contains a submit button btnSubmit
    >
    > Pageload code behind file:
    > btnSubmit.Attributes.Add("onClick", "return doit();")
    >
    > javascript:
    >
    > <script language="javascript">
    > function doit()
    > {
    > document.body.style.cursor='wait'
    > }
    > </script>
    >
    > btnsubmit on-click code executes as normal after hourglass displayed
    >
    > Thanks


    What if you use "doit();" instead of "return doit();" ? Asp.net adds it's own code
    to that event handler but that now never gets reached, as you returned already.
    As a remark: do not forget the ";" as it separates your code from the .net added code.

    Hans Kesting
    Hans Kesting, Jul 1, 2004
    #2
    1. Advertising

  3. Dick W

    Dick W Guest

    Hans,

    thanks for the quick response. Removing the return does trigger the
    validation controls but, having set the Hourglass it stays like that.
    Nearly there




    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Dick W, Jul 1, 2004
    #3
  4. Dick W

    Peter Blum Guest

    Consider a different angle. Add your javascript into the <form onsubmit="">
    event.
    Use Page.RegisterOnSubmitStatement().

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Dick W" <> wrote in message
    news:%...
    >
    > Hans,
    >
    > thanks for the quick response. Removing the return does trigger the
    > validation controls but, having set the Hourglass it stays like that.
    > Nearly there
    >
    >
    >
    >
    > *** Sent via Devdex http://www.devdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Peter Blum, Jul 2, 2004
    #4
    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. Gary Nelson

    Upgrade from aspnet 1.1 to aspnet 2.0

    Gary Nelson, Oct 14, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    469
    Gary Nelson
    Oct 14, 2005
  2. Replies:
    7
    Views:
    626
    Juan T. Llibre
    Mar 23, 2007
  3. Grigory Temchenko
    Replies:
    0
    Views:
    319
    Grigory Temchenko
    Dec 28, 2008
  4. Brian Schuth
    Replies:
    0
    Views:
    263
    Brian Schuth
    Sep 8, 2003
  5. Alfred Sehmueller
    Replies:
    0
    Views:
    253
    Alfred Sehmueller
    Feb 20, 2004
Loading...

Share This Page