button attributes disable validation

Discussion in 'ASP .Net' started by Tim Meagher, Aug 31, 2005.

  1. Tim Meagher

    Tim Meagher Guest

    I am trying to use both validation controls and to add submit button
    attributes, but when I add the button attributes, the javascript fpr the
    validation controls is no longer created for the page. How can I use both?

    Thank you,

    Tim Meagher
     
    Tim Meagher, Aug 31, 2005
    #1
    1. Advertising

  2. Tim Meagher

    Peter Blum Guest

    Hi Tim,

    If I understand you correctly, you are trying to add javascript to the
    submit button and it breaks client-side validation. If that's the case, see
    this article: http://aspalliance.com/699 in the topic "Messageboxes and
    Validation". While it shows how to add a confirm prompt, you can use the
    technique shown to add any javascript to a button.

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

    "Tim Meagher" <> wrote in message
    news:Oa%...
    >I am trying to use both validation controls and to add submit button
    > attributes, but when I add the button attributes, the javascript fpr the
    > validation controls is no longer created for the page. How can I use
    > both?
    >
    > Thank you,
    >
    > Tim Meagher
    >
    >
     
    Peter Blum, Aug 31, 2005
    #2
    1. Advertising

  3. Tim Meagher

    Tim Meagher Guest

    Peter,

    Thank you for this information. It has shown me how to invoke the
    validation objects when the submit button is pressed as part of the server
    side event handler - and it appears that the validation should be added to
    server-side handling especially for browsers that cannot handle client-side
    validation.

    I would still be interested in knowing how to run the client-side validation
    in conjunction with the confirm feature that I added to my submit button to
    avoid a postback.

    Regards,

    Tim

    "Peter Blum" <> wrote in message
    news:...
    > Hi Tim,
    >
    > If I understand you correctly, you are trying to add javascript to the
    > submit button and it breaks client-side validation. If that's the case,

    see
    > this article: http://aspalliance.com/699 in the topic "Messageboxes and
    > Validation". While it shows how to add a confirm prompt, you can use the
    > technique shown to add any javascript to a button.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Tim Meagher" <> wrote in message
    > news:Oa%...
    > >I am trying to use both validation controls and to add submit button
    > > attributes, but when I add the button attributes, the javascript fpr the
    > > validation controls is no longer created for the page. How can I use
    > > both?
    > >
    > > Thank you,
    > >
    > > Tim Meagher
    > >
    > >

    >
    >
     
    Tim Meagher, Aug 31, 2005
    #3
  4. Tim Meagher

    Tim Meagher Guest

    Hi Peter,

    I also found out that one can selectively enable and disable client side
    validation merely by setting the enable flag of the validation control to
    true or false. I was able to take advantage of that in my code to simplify
    validation for all my validation controls by creating the two following
    methods:

    // Returns true if validation succeeds for the given validation control, or,

    // if the control is not enabled (in which case no validation should occur)

    private bool IsValidControl(BaseValidator control)

    {

    if (!control.Enabled)

    {

    return true;

    }

    control.Validate();

    return (control.IsValid);

    }

    private bool IsValidForm()

    {

    bool valid = true;

    valid &= IsValidControl(ReqValUserID);

    valid &= IsValidControl(RegexUserID);

    valid &= IsValidControl(ReqValFirstName);

    valid &= IsValidControl(RegexFirstName);

    valid &= IsValidControl(RegexMiddleInitial);

    valid &= IsValidControl(ReqValLastName);

    valid &= IsValidControl(RegexLastName);

    valid &= IsValidControl(ReqValEmail);

    valid &= IsValidControl(RegexEmail);

    valid &= IsValidControl(ReqValPhone);

    valid &= IsValidControl(RegexPhone);

    valid &= IsValidControl(ReqValNotes);

    valid &= IsValidControl(ReqValReject);

    return valid;

    }



    Finally, I invoked the IsValidForm() method in my submit button onclick
    handler as follows:

    if (!IsValidForm())

    {

    return;

    }


    Tim

    "Peter Blum" <> wrote in message
    news:...
    > Hi Tim,
    >
    > If I understand you correctly, you are trying to add javascript to the
    > submit button and it breaks client-side validation. If that's the case,

    see
    > this article: http://aspalliance.com/699 in the topic "Messageboxes and
    > Validation". While it shows how to add a confirm prompt, you can use the
    > technique shown to add any javascript to a button.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Tim Meagher" <> wrote in message
    > news:Oa%...
    > >I am trying to use both validation controls and to add submit button
    > > attributes, but when I add the button attributes, the javascript fpr the
    > > validation controls is no longer created for the page. How can I use
    > > both?
    > >
    > > Thank you,
    > >
    > > Tim Meagher
    > >
    > >

    >
    >
     
    Tim Meagher, Aug 31, 2005
    #4
  5. Tim Meagher

    Peter Blum Guest

    Hi Tim,

    You wrote:
    > I would still be interested in knowing how to run the client-side
    > validation
    > in conjunction with the confirm feature that I added to my submit button
    > to
    > avoid a postback.


    I'm confused by this. I pointed you to a portion of my article that
    specifically handles client-side confirm that either permits or blocks
    submitting the page.

    FYI: This is easier in my Professional Validation And More. I give you
    properties to create confirm messages and run the confirm either before or
    after page validation runs on the client side. I also give you a hook to add
    any other javascript you want into the page validation process so you can
    stop the page from submitting for your own reasons.

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

    "Tim Meagher" <> wrote in message
    news:...
    > Peter,
    >
    > Thank you for this information. It has shown me how to invoke the
    > validation objects when the submit button is pressed as part of the server
    > side event handler - and it appears that the validation should be added to
    > server-side handling especially for browsers that cannot handle
    > client-side
    > validation.
    >
    > I would still be interested in knowing how to run the client-side
    > validation
    > in conjunction with the confirm feature that I added to my submit button
    > to
    > avoid a postback.
    >
    > Regards,
    >
    > Tim
    >
    > "Peter Blum" <> wrote in message
    > news:...
    >> Hi Tim,
    >>
    >> If I understand you correctly, you are trying to add javascript to the
    >> submit button and it breaks client-side validation. If that's the case,

    > see
    >> this article: http://aspalliance.com/699 in the topic "Messageboxes and
    >> Validation". While it shows how to add a confirm prompt, you can use the
    >> technique shown to add any javascript to a button.
    >>
    >> --- Peter Blum
    >> www.PeterBlum.com
    >> Email:
    >> Creator of "Professional Validation And More" at
    >> http://www.peterblum.com/vam/home.aspx
    >>
    >> "Tim Meagher" <> wrote in message
    >> news:Oa%...
    >> >I am trying to use both validation controls and to add submit button
    >> > attributes, but when I add the button attributes, the javascript fpr
    >> > the
    >> > validation controls is no longer created for the page. How can I use
    >> > both?
    >> >
    >> > Thank you,
    >> >
    >> > Tim Meagher
    >> >
    >> >

    >>
    >>

    >
    >
     
    Peter Blum, Sep 2, 2005
    #5
    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. sylvia sil
    Replies:
    1
    Views:
    633
    Curt_C [MVP]
    Dec 29, 2004
  2. Max
    Replies:
    1
    Views:
    499
    Joe Kesselman
    Sep 22, 2006
  3. Chuck
    Replies:
    0
    Views:
    284
    Chuck
    Nov 10, 2003
  4. Jukka K. Korpela
    Replies:
    15
    Views:
    557
    Joy Beeson
    Apr 11, 2013
  5. Jonathan N. Little
    Replies:
    42
    Views:
    1,233
    Christoph Becker
    Apr 13, 2013
Loading...

Share This Page