Results 1 to 25 of 25

Thread: [RESOLVED] regular expression validator no dot

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Resolved [RESOLVED] regular expression validator no dot

    Hello does someone know where to get the regular expression validator that "." dot is not allowed but other characters are acceptable.

  2. #2
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: regular expression validator no dot

    Not tested but this may work
    Code:
    [^\.]
    I generally use expressions from regexlib.com

  3. #3
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    That is the one I would use too.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    I did that but now.. any words inside are considered having dot *confused* I just want to limit the .dot

  5. #5
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    You don't need other words, this says match everything BUT the dot.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    But now I typed "Test" or anything else, it still considered wrong... I only want to display the error message when the user types "test.testing" or something that has dot in it.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    This is for the regularexpression validator.. not sure if that is different than regular regular expression

  8. #8
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    This expression ignores the dot that's all it doesn't report the dot it reports everything else.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    So how can I resolve this then? I want the regular expression to accept everything but the "dot" ... am I making sense?

  10. #10
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    See it depends on what your trying to do.

    Is.This.Ok

    Meaning should you get I,s,t,h,i,s,o,k

    Or do you want to get the words as whole words? where exactly are you inputing this expression?

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    It's the asp.net regular expression validator control. I put it next to the user name text field. So if the user puts "Is.This.OK" it will say "Error, no period/dot character" then when the user removes "Is this ok", then the error should go away. But right now I am applying that [^\.], it still says wrong even though I put " is this ok"

  12. #12
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    Well it would be wrong because it contains no dot. Your using it as a true/false value but that's not how reg-ex works intrinsically. I've never used that control but that would make sense since reg-ex finds patterns and not determines state.

    See what that expression does is NOT find a period. That means it reports back everything that is NOT a period it doesn't report back true or false. You would be better of doing a string.contains(".") instead of a regular expression.

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    Then how come Email regular expression would work with that control?

  14. #14
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    I dunno to be honest!

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    Can someone help? I really need that validation.. where is medhak1 and gep? LOL

  16. #16
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    What happens if you but that regex in with Is.This.Ok?

    You might just need to reverse the logic in that case you need [\.]

    But I recon that controls works via a none or all case IE it would have to match everything. So consider the email addy, well that has everything always the same. IE you can make an expression that captures everything. But your capture is two ambiguous from what I know of it.

    I would need an example of a good use and a bad use to write an expression.

  17. #17
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: regular expression validator no dot

    Try this in regular expression validator:
    Code:
    ValidationExpression="^[^.]*$"

  18. #18
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: regular expression validator no dot

    That works on my end no dots:

    I had: ^[^.]*\b

    I couldn't figure out the end assertion $ (Which is the end of line).

    Rep for you!

  19. #19
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: regular expression validator no dot

    Quote Originally Posted by DeanMc View Post
    Rep for you!
    Yesss.. they are always needed..

  20. #20

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    Oh rjv.. that's awesome that's what I am looking for; however, it looks like it only checks one dot... the second dot, it just ignored. Ex: Is.this.ok ... it doesn't throw error.

  21. #21
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: regular expression validator no dot

    That's surprising. It shows the validation error message in my test page. Here is the code:
    markup
    Code:
    <&#37;@ Page Language="C#" AutoEventWireup="true" CodeFile="Validator.aspx.cs" Inherits="ForumQns_Validator" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox runat="server" ID="txtTest" ></asp:TextBox>
            <asp:Button runat="server" ID="btnTest" Text="Test!" OnClick="OnTestClick" />
            <asp:RegularExpressionValidator runat="server" ID="revTest" ErrorMessage="Invalid"
             ControlToValidate="txtTest" ValidationExpression="^[^.]*$"></asp:RegularExpressionValidator>
        </div>
        </form>
    </body>
    </html>
    Code behind (it's empty on purpose)
    Code:
    //removed using statements
    public partial class ForumQns_Validator : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        protected void OnTestClick(object sender, EventArgs e)
        {
        }
    }
    Can you create a new page with the above code and check if it works?

  22. #22
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: regular expression validator no dot

    I guess you are missing the * towards the end of regular expression.

  23. #23
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: regular expression validator no dot

    Hey,

    Looks like I arrived to late to help out on this thread

    Good work Dean and rjv_rnjn!!!

    Gary

  24. #24

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: regular expression validator no dot

    Dang... I swear yesterday wasn't working. Today after restart tthe machine, it decides to work kudos to Rjv.

  25. #25
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] regular expression validator no dot

    If in doubt, switch it off, and switch it on again

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width