Valid regular expression not working with validator control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Jocelyn

    Valid regular expression not working with validator control

    Hi

    I get a JavaScript error with this expression when using the
    RegExpValidator . Also if I switch off client script the server side code
    validator finds a match regardless of the entered string.

    (?<!@emailaddre ssnotallowed\.o rg)$

    Is there a way of writing this so it works with the validator in both client
    side and server side?

    Thanks
    Andrew


  • Jesse Houwing

    #2
    Re: Valid regular expression not working with validator control

    Hello Andrew,
    Hi
    >
    I get a JavaScript error with this expression when using the
    RegExpValidator . Also if I switch off client script the server side
    code validator finds a match regardless of the entered string.
    >
    (?<!@emailaddre ssnotallowed\.o rg)$
    >
    Is there a way of writing this so it works with the validator in both
    client side and server side?
    Look behinds are not supported in Client Side code. So you need to rewrite
    this to either a full expression or to use a look ahead like this:

    ^regexuptothe@( ?!emailaddressn otallowed\.org$ )restofthedomai nregex$

    --
    Jesse Houwing
    jesse.houwing at sogeti.nl


    Comment

    • Andrew Jocelyn

      #3
      Re: Valid regular expression not working with validator control

      Hi

      thanks for the tip. I still can't get what I want to work. I'm using
      Expresso to test.

      Basically I want to make sure that if an input text includes a certain
      domain then validation fails, e.g.

      anyone@not-allowed-domain.com fails
      anyone@allowed-domain.com succeeds

      Please bear with me as I'm a complete novice with regular expressions.

      Thanks again
      Andrew


      "Jesse Houwing" <jesse.houwing@ newsgroup.nospa mwrote in message
      news:21effc9046 4ad8ca4c7399891 14d@news.micros oft.com...
      Hello Andrew,
      >
      >Hi
      >>
      >I get a JavaScript error with this expression when using the
      >RegExpValidato r. Also if I switch off client script the server side
      >code validator finds a match regardless of the entered string.
      >>
      >(?<!@emailaddr essnotallowed\. org)$
      >>
      >Is there a way of writing this so it works with the validator in both
      >client side and server side?
      >
      Look behinds are not supported in Client Side code. So you need to rewrite
      this to either a full expression or to use a look ahead like this:
      >
      ^regexuptothe@( ?!emailaddressn otallowed\.org$ )restofthedomai nregex$
      >
      --
      Jesse Houwing
      jesse.houwing at sogeti.nl
      >
      >

      Comment

      • Jesse Houwing

        #4
        Re: Valid regular expression not working with validator control

        Hello Andrew,
        Hi
        >
        thanks for the tip. I still can't get what I want to work. I'm using
        Expresso to test.
        >
        Basically I want to make sure that if an input text includes a certain
        domain then validation fails, e.g.
        >
        anyone@not-allowed-domain.com fails
        anyone@allowed-domain.com succeeds
        Please bear with me as I'm a complete novice with regular expressions.
        ^[^@]+@(?!not-allowed-domain.com$).*$

        should do, though it doesn't check the syntax of the email address itself,
        it does exclude the domain you want.

        Jesse

        >
        Thanks again
        Andrew
        "Jesse Houwing" <jesse.houwing@ newsgroup.nospa mwrote in message
        news:21effc9046 4ad8ca4c7399891 14d@news.micros oft.com...
        >
        >Hello Andrew,
        >>
        >>Hi
        >>>
        >>I get a JavaScript error with this expression when using the
        >>RegExpValidat or. Also if I switch off client script the server side
        >>code validator finds a match regardless of the entered string.
        >>>
        >>(?<!@emailadd ressnotallowed\ .org)$
        >>>
        >>Is there a way of writing this so it works with the validator in
        >>both client side and server side?
        >>>
        >Look behinds are not supported in Client Side code. So you need to
        >rewrite this to either a full expression or to use a look ahead like
        >this:
        >>
        >^regexuptothe@ (?!emailaddress notallowed\.org $)restofthedoma inregex$
        >>
        >--
        >Jesse Houwing
        >jesse.houwin g at sogeti.nl
        --
        Jesse Houwing
        jesse.houwing at sogeti.nl


        Comment

        Working...