Custom Validation not working for character limit

Umbraco 13.5.2

I cannot get a custom validation rule to work, despite trying it multiple ways. Take the following sample sentence:

“See the historical territory of the Umatilla People, how our ancestors traveled through the Columbia Plateau region and interacted with each other, and hear traditional songs while you view.”

It is exactly 190 characters. So, theoretically, the following RegEx should allow it:

^.{0,275}$

Right? Well, it doesn’t. Nor does it allow two instances of the sentence (380 characters) or even a blank value (0 characters). An online RegEx tester says it works though, even when set to exactly 190 characters, like this…

Image showing same expression with 189 as the limit to show it works:

However, I have a text field set up this way (using a 190 character limit as an example)…

And yet it will not accept any input now. Not 0 characters, not 190 characters, not more than 190 characters. It won’t accept anything. Here is the field on the component:




I don’t understand what I need to do to get this to work. I read this article regarding Umbraco Forms:

but while adding the code to my project didn’t produce errors and built successfully, it didn’t actually create a new validation rule in the dropdown.

Can someone please help me get a RegEx rule that effectively says “I don’t care what characters you put into this textbox, but I don’t want you to put more than 275 of those characters in it”?

Hi Chris,

Without knowing anything specific about it, my immediate guess/hunch is that the Regex is being applied to the JSON blob that a RichText field essentially is (well, escaped HTML as JSON), which is probably already way beyond 275 characters.

Have you tried applying that same Regex to a TextArea field, to see if that can be made to work? That should at least make a clear case for a bug report.

I was looking up the URL for issues and saw this one immediately: Turns out, there’s already a reported issue for this, actually: RTE custom regex validation fails · Issue #19044 · umbraco/Umbraco-CMS · GitHub

/Chriztian

1 Like

Hi Chriztian,

While that doesn’t “solve” my issue, it definitely answers it! Thanks so much for taking the time to reply! :slight_smile:

I suppose since the most recent post on that issue is only a week or two ago, I should not hold my breath for it being resolved any time soon, eh? Haha!

Thanks again for the good direction!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.