how find the count the charecters count which are in the formate of html

hi iam using richTextFieldWithTables component where i cant add validations that i have enterd 6 charectes name and clicked on enter it is showing count of 11  but i need to writea condintion if a user enters 4000 charectrs he should not procede further how can we give validation bcz on chage of size of text or on click on enter or by adding tables charcters count is getting count i had used strip html fucntion but it dosent help me any suggestions please 

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    Hello ,

    Since it is a rich text field it collects your data with the characters such as <p>,</p>.

    so try using the below code.

    you might want to add separate with <br> also if you want to avoid counting any blank returns.

    Hopefully this is helpful.

    a!localVariables(
      local!richText,
      local!onlyText: if(
        a!isNullOrEmpty(local!richText),
        {},
        split(local!richText, "</p>")
      ),
      local!last: split(local!onlyText, "<p>"),
      local!textwithSpaces: tostring(
        remove(
          local!last,
          wherecontains(null(), local!last)
        )
      ),
      local!textWithNoSpaces: tostring(
        stripwith(
          stripwith(local!textwithSpaces, " "),
          ";"
        )
      ),
      {
        richTextFieldWithTables(
          label: "My Text Field",
          richTextSaveInto: local!richText,
          richTextValue: local!richText
        ),
        a!richTextDisplayField(
          label: "Count",
          value: a!richTextItem(text: len(local!textWithNoSpaces))
        )
      }
    )

    You can add a validation using the local variable which has the count and then write a validation accordingly.

  • 0
    Certified Lead Developer

    len(striphtml("<p>Hello World</p>"))