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.
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?
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.
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.
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?
is working on a reply...