Jump to content

[FYI] Removing HTML tags to data inputs using RICH text editor using JavaScript


Recommended Posts

I found another solution in removing HTML tags in the data saved in Rich text editor. This is more if an alternative to this solution. Specially for those who doesn't have access to Triggered action.

  1. First you would need another field in your table that will store the plain text version of the actual input.
  2. Put that field in your Submission form and add a HEADER and FOOTER in your DataPage.
  3. Go the the FOOTER of your DataPage and disable the HTML editor in the Advanced tab.
  4. Paste the code below in your footer:

 

<script type="text/javascript">

//This will hide the field for the "plain" text
var non_formatted_txt = document.querySelector("#InsertRecordFIELDNAME_2");
non_formatted_txt.style.display = "none";

document.addEventListener('BeforeFormSubmit', function(event) {

//This will replace all the HTML tags with blank
var input = document.querySelector("#InsertRecordFIELDNAME_1").value.replace(/<\/?[^>]+(>|$)/g, "");

non_formatted_txt.value = input;
});
</script>

NOTE: replace FIELDNAME_2 with the actual fieldname of your field for the "plain" text and replace FIELDNAME_1 with the actual field name of the rich text editor field.

Sample input :

   image.png.c734b06bdb9f96d5e706c4dc0f50e05f.png

Actual table value:

image.png.aaa2ba2f58e4960197f8ed8023f508f0.png

Non formatted value:

image.png.83cccd5f5033247417034cd6c9ed7d44.png

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...