Combine regular expression validator with javascript function?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dot net work

    Combine regular expression validator with javascript function?

    Hello.

    Say I have a .net textbox that uses a .net regularexpressi onvalidator.
    If the regular expression fails, is it possible to launch a small
    client side javascript function to do something, such as change the
    border color of the textbox to red? That would look quite nice: if
    the expression fails, the red validator text is shown, plus the
    textbox's border goes red.

    TIA,
    -dnw.
  • Dot net work

    #2
    Re: Combine regular expression validator with javascript function?

    I was not able to somehow combine the regular expression validator
    control with a client side javascript function, so instead I took the
    regular expression that I needed and put it inside a custom validator
    client side function, then added on some extra javascript that changed
    the textbox border to red.

    -dnw.

    dotnw@hotmail.c om (Dot net work) wrote in message news:<77b8c5a9. 0405071033.6a9a 6e3a@posting.go ogle.com>...[color=blue]
    > Hello.
    >
    > Say I have a .net textbox that uses a .net regularexpressi onvalidator.
    > If the regular expression fails, is it possible to launch a small
    > client side javascript function to do something, such as change the
    > border color of the textbox to red? That would look quite nice: if
    > the expression fails, the red validator text is shown, plus the
    > textbox's border goes red.
    >
    > TIA,
    > -dnw.[/color]

    Comment

    • Peter Blum

      #3
      Re: Combine regular expression validator with javascript function?

      There is a solution that avoids rewriting every validator. It requires using
      a replacement to Microsoft's validators that is designed to handle this kind
      of communication. Microsoft's validators are limited to showing an error
      message in the location of the validator. There are other ways to
      communicate to the user: setting focus to the field, changing the field,
      label or background color, blinking the error message and putting up an
      alert. "Profession al Validation And More"
      (http://www.peterblum.com/vam/home.aspx) has all of these capabilities
      supporting its 22 validators. Its designed to avoid writing custom code and
      hacks due to the many limitations of Microsoft's validators.

      --- Peter Blum

      Email: PLBlum@PeterBlu m.com
      Creator of "Profession al Validation And More" at



      "Dot net work" <dotnw@hotmail. com> wrote in message
      news:77b8c5a9.0 405080030.6c4dd 9da@posting.goo gle.com...[color=blue]
      > I was not able to somehow combine the regular expression validator
      > control with a client side javascript function, so instead I took the
      > regular expression that I needed and put it inside a custom validator
      > client side function, then added on some extra javascript that changed
      > the textbox border to red.
      >
      > -dnw.
      >
      > dotnw@hotmail.c om (Dot net work) wrote in message[/color]
      news:<77b8c5a9. 0405071033.6a9a 6e3a@posting.go ogle.com>...[color=blue][color=green]
      > > Hello.
      > >
      > > Say I have a .net textbox that uses a .net regularexpressi onvalidator.
      > > If the regular expression fails, is it possible to launch a small
      > > client side javascript function to do something, such as change the
      > > border color of the textbox to red? That would look quite nice: if
      > > the expression fails, the red validator text is shown, plus the
      > > textbox's border goes red.
      > >
      > > TIA,
      > > -dnw.[/color][/color]


      Comment

      Working...