Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrew 19 posts 39 karma points
    Jun 04, 2012 @ 19:41
    Andrew
    0

    Regex problem on document type property

    Hi, I have a "Product" document type with a "Cost Per Unit" property (using "Numeric" data type) that I want to validate with regex. Here's the regex I am using: \$?\d{1,6}(\.\d{2})?

    This works fine in RegExr (http://gskinner.com/RegExr/). That is, it works as expected. It accepts numbers with 1 to 6 digits, plus optionally a dollar sign and period plus 2 decimal places. However, when I create a product document and enter what SHOULD be a valid monetary amount, it does not accept it - by which I mean, it clears the value and tells me the "Cost Per Unit" field is required.

    Wasn't sure if this was a bug or just something I'm doing wrong. I did also try it with / on both sides and with parentheses in various places.

    I'm using umbraco v 4.7.1.1.

    I appreciate any help.

  • Sean Mooney 131 posts 158 karma points c-trib
    Jun 04, 2012 @ 20:20
    Sean Mooney
    0

    Have you tried changing it to a "Textstring", with the same regulare expression?

    I would imagine that the $ would error out before your RegEx is called, becuase $ is not a numeric value.

  • Andrew 19 posts 39 karma points
    Jun 04, 2012 @ 22:05
    Andrew
    0

    Yeah, it's actually the period that causes the problem. Apparently "numeric" can't accept decimals. That seems strange to me. I know it's not the dollar sign because I also tried some numbers without using it - same error. But integers DO work. I did exactly what you said and it works fine. Why doesn't numeric allow decimals?

Please Sign in or register to post replies

Write your reply to:

Draft