Search code examples
javascriptcumbraco

How to add validation that will allow new lines in Umbraco


Currently i have validation on my text area which does not allow new lines being entered.

It looks like this in the umbraco validation field: ^.{1,3000}$

Any ideas on how to allow new lines and line breaks ?


Solution

  • That regular expression basically says allow ANY character EXCEPT line breaks, between 1 and 3000 times. If you change it to:

    ^[\s\S]{1,3000}$
    

    It should allow ANY character, including line breaks. The new version says match any character that is either whitespace, or not whitespace, which is effectively any character.