RegularExpressionValidator

Discussion in 'ASP .Net' started by simonZ, Dec 21, 2006.

  1. simonZ

    simonZ Guest

    I have RegularExpressionValidator which validate one text box.
    When my text box is validated on client I would like to do something else.

    Is there some client event of RegularExpressionValidator?

    Something like after validate?

    something like:

    <script language="javaScript">
    function afterValidate(arg){
    if (arg.isValid )
    {
    //do something
    }
    }
    </script>

    regards,S
    simonZ, Dec 21, 2006
    #1
    1. Advertising

  2. simonZ

    simonZ Guest

    Thank you, Milosz

    this was exactly what I needed.

    Regards,S

    "Milosz Skalecki" <> wrote in message
    news:...
    > Hi Simon,
    >
    > Client side validation API:
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp
    >
    > There are many ways to accomplish this task:
    >
    > - you can force validators to run their validation methods by calling
    > ValidatorValidate(val)
    > - instead of using reqularexpressionvalidator, use customvalidator in
    > conjunction with clinetfunctionname property, and Regex DOM object (it's
    > easy to incorporate the same functionality as regularexpressionvalidator)
    >
    > example :
    >
    >
    > <asp:CustomValidator ID="CustomValidator1" runat="server"
    > ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
    > ErrorMessage="try again...."
    > OnServerValidate="CustomValidator1_ServerValidate"/>
    >
    > <script runat="server">
    >
    > protected void CustomValidator1_ServerValidate(object source,
    > ServerValidateEventArgs args)
    > {
    > args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
    > "[0-9]+");
    > }
    >
    > </script>
    >
    > <script language="javascript">
    > function MyValidationFunction(src, e)
    > {
    > e.IsValid = e.Value.match('[0-9]+');
    >
    > // do something here...
    > }
    > </script>
    > --
    > Milosz Skalecki
    > MCAD
    >
    >
    > "simonZ" wrote:
    >
    >> I have RegularExpressionValidator which validate one text box.
    >> When my text box is validated on client I would like to do something
    >> else.
    >>
    >> Is there some client event of RegularExpressionValidator?
    >>
    >> Something like after validate?
    >>
    >> something like:
    >>
    >> <script language="javaScript">
    >> function afterValidate(arg){
    >> if (arg.isValid )
    >> {
    >> //do something
    >> }
    >> }
    >> </script>
    >>
    >> regards,S
    >>
    >>
    >>
    simonZ, Dec 21, 2006
    #2
    1. Advertising

  3. simonZ

    bruce barker Guest

    note, this article is for version 1. client side validation is simular
    for version 2, but there are implementation differences (javascript
    variables instead of spans, for example).

    -- bruce (sqlwork.com)

    Milosz Skalecki wrote:
    > Hi Simon,
    >
    > Client side validation API:
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp
    >
    > There are many ways to accomplish this task:
    >
    > - you can force validators to run their validation methods by calling
    > ValidatorValidate(val)
    > - instead of using reqularexpressionvalidator, use customvalidator in
    > conjunction with clinetfunctionname property, and Regex DOM object (it's
    > easy to incorporate the same functionality as regularexpressionvalidator)
    >
    > example :
    >
    >
    > <asp:CustomValidator ID="CustomValidator1" runat="server"
    > ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
    > ErrorMessage="try again...."
    > OnServerValidate="CustomValidator1_ServerValidate"/>
    >
    > <script runat="server">
    >
    > protected void CustomValidator1_ServerValidate(object source,
    > ServerValidateEventArgs args)
    > {
    > args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
    > "[0-9]+");
    > }
    >
    > </script>
    >
    > <script language="javascript">
    > function MyValidationFunction(src, e)
    > {
    > e.IsValid = e.Value.match('[0-9]+');
    >
    > // do something here...
    > }
    > </script>
    bruce barker, Dec 21, 2006
    #3
  4. simonZ

    simonZ Guest

    Well, it doesn't help much, because client side validation doesn't work in
    firefox.
    So, I must create on some other way.

    regards,Simon


    "simonZ" <> wrote in message
    news:%...
    > Thank you, Milosz
    >
    > this was exactly what I needed.
    >
    > Regards,S
    >
    > "Milosz Skalecki" <> wrote in message
    > news:...
    >> Hi Simon,
    >>
    >> Client side validation API:
    >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp
    >>
    >> There are many ways to accomplish this task:
    >>
    >> - you can force validators to run their validation methods by calling
    >> ValidatorValidate(val)
    >> - instead of using reqularexpressionvalidator, use customvalidator in
    >> conjunction with clinetfunctionname property, and Regex DOM object (it's
    >> easy to incorporate the same functionality as regularexpressionvalidator)
    >>
    >> example :
    >>
    >>
    >> <asp:CustomValidator ID="CustomValidator1" runat="server"
    >> ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
    >> ErrorMessage="try again...."
    >> OnServerValidate="CustomValidator1_ServerValidate"/>
    >>
    >> <script runat="server">
    >>
    >> protected void CustomValidator1_ServerValidate(object source,
    >> ServerValidateEventArgs args)
    >> {
    >> args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
    >> "[0-9]+");
    >> }
    >>
    >> </script>
    >>
    >> <script language="javascript">
    >> function MyValidationFunction(src, e)
    >> {
    >> e.IsValid = e.Value.match('[0-9]+');
    >>
    >> // do something here...
    >> }
    >> </script>
    >> --
    >> Milosz Skalecki
    >> MCAD
    >>
    >>
    >> "simonZ" wrote:
    >>
    >>> I have RegularExpressionValidator which validate one text box.
    >>> When my text box is validated on client I would like to do something
    >>> else.
    >>>
    >>> Is there some client event of RegularExpressionValidator?
    >>>
    >>> Something like after validate?
    >>>
    >>> something like:
    >>>
    >>> <script language="javaScript">
    >>> function afterValidate(arg){
    >>> if (arg.isValid )
    >>> {
    >>> //do something
    >>> }
    >>> }
    >>> </script>
    >>>
    >>> regards,S
    >>>
    >>>
    >>>

    >
    >
    simonZ, Dec 22, 2006
    #4
  5. Hi Simon,

    Yes, it does, show me the code you're having problems with

    Regards
    --
    Milosz Skalecki
    MCAD


    "simonZ" wrote:

    > Well, it doesn't help much, because client side validation doesn't work in
    > firefox.
    > So, I must create on some other way.
    >
    > regards,Simon
    >
    >
    > "simonZ" <> wrote in message
    > news:%...
    > > Thank you, Milosz
    > >
    > > this was exactly what I needed.
    > >
    > > Regards,S
    > >
    > > "Milosz Skalecki" <> wrote in message
    > > news:...
    > >> Hi Simon,
    > >>
    > >> Client side validation API:
    > >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp
    > >>
    > >> There are many ways to accomplish this task:
    > >>
    > >> - you can force validators to run their validation methods by calling
    > >> ValidatorValidate(val)
    > >> - instead of using reqularexpressionvalidator, use customvalidator in
    > >> conjunction with clinetfunctionname property, and Regex DOM object (it's
    > >> easy to incorporate the same functionality as regularexpressionvalidator)
    > >>
    > >> example :
    > >>
    > >>
    > >> <asp:CustomValidator ID="CustomValidator1" runat="server"
    > >> ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
    > >> ErrorMessage="try again...."
    > >> OnServerValidate="CustomValidator1_ServerValidate"/>
    > >>
    > >> <script runat="server">
    > >>
    > >> protected void CustomValidator1_ServerValidate(object source,
    > >> ServerValidateEventArgs args)
    > >> {
    > >> args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
    > >> "[0-9]+");
    > >> }
    > >>
    > >> </script>
    > >>
    > >> <script language="javascript">
    > >> function MyValidationFunction(src, e)
    > >> {
    > >> e.IsValid = e.Value.match('[0-9]+');
    > >>
    > >> // do something here...
    > >> }
    > >> </script>
    > >> --
    > >> Milosz Skalecki
    > >> MCAD
    > >>
    > >>
    > >> "simonZ" wrote:
    > >>
    > >>> I have RegularExpressionValidator which validate one text box.
    > >>> When my text box is validated on client I would like to do something
    > >>> else.
    > >>>
    > >>> Is there some client event of RegularExpressionValidator?
    > >>>
    > >>> Something like after validate?
    > >>>
    > >>> something like:
    > >>>
    > >>> <script language="javaScript">
    > >>> function afterValidate(arg){
    > >>> if (arg.isValid )
    > >>> {
    > >>> //do something
    > >>> }
    > >>> }
    > >>> </script>
    > >>>
    > >>> regards,S
    > >>>
    > >>>
    > >>>

    > >
    > >

    >
    >
    >
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=, Dec 22, 2006
    #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. Oleg Ogurok
    Replies:
    1
    Views:
    6,292
    William F. Robertson, Jr.
    Jun 25, 2003
  2. Helixpoint

    RegularExpressionValidator for money??

    Helixpoint, Jun 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,746
    Helixpoint
    Jul 1, 2003
  3. Salim Afþar

    regularexpressionvalidator numeric control

    Salim Afþar, Aug 4, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,559
    Vincent V
    Aug 5, 2003
  4. BH
    Replies:
    0
    Views:
    505
  5. Ananda Sim
    Replies:
    0
    Views:
    479
    Ananda Sim
    Aug 18, 2003
Loading...

Share This Page