How to prevent html tags in nicEditor?

I want to prevent writing html tags in nicEditor.

<div id="sample">
  <script  type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> <script type="text/javascript">
//<![CDATA[
        bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
  //]]>
  </script>
  <textarea onblur="this.value = this.value.replace(/<\/?[^>]+>/gi, '')" name="process" style="width: 300px; height: 100px;" id="process">
         hello <b>world</b>
  </textarea>
</div>  

I have tried above regex..but it doesn't work.. I am using the same regex onblur="this.value = this.value.replace(/<\/?[^>]+>/gi, '')" for simple textbox.and it works fine.

I also want to know that, is it the proper way to prevent html tags from user inputs for security purpose?

Answers


Try to test the order of priority of the events. Attach two handlers form.submit and textarea.blur and e.preventDefault inside submit. And use inside both of them console.log('submit') and console.log('blur') to see which one fires before. Cause the problem may be in the submit which fires before blur


Need Your Help

can mingw build a visual studio-2010 project?

visual-studio-2010 makefile mingw mingw32

I have a visual studio-2010 project which contains lots of source files and header files. Now I need to autobuild this project under the latest Debian GNU/Linux. So I choose to use MinGW. But I nee...

std::function which returns any summable type?

c++ templates c++11 openmp std-function

My graph data structure for parallel algorithms has the following iterator method:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.