Posts

Showing posts from January 8, 2019

Only allow certain tags in contenteditable div

Image
0 I have a contenteditable div and using keyboard shortcuts like ctrl+i the user is able to format the text. And as they type the innerHTML changes reflecting the tags i.e: Hello&nbsp;<i>thanks for&nbsp;<br><br>for showing up<b>&nbsp;y'all b</b></i> This is fine, and works well for my purposes. but the issue arises that when I go to print the html in a different div IF a user adds any other html tags, they could really mess up the application. For instance, if they added a <script> tag or style etc.. How do I make it that the user is only allowed to add <i> , <br> , <b> , <s> , and &nbsp; without being able to add anything else? Any ideas? Thank you javascript jquery angula