How to validate TinyMCE textarea in ASP.NET MVC?

How can i validate TinyMCE using MVC and razor? Currently, i was trying to validate it using Model validations but it is not working and not showing any errors even when TinyMCE textarea is blank, so how can i validate it? here is my javascript code

<script type="text/javascript">
$(document).ready(function () {
  selector: 'textarea',
  height: 500,
  menubar: false,
  plugins: [
    'advlist autolink lists link image charmap print preview anchor textcolor',
    'searchreplace visualblocks code fullscreen',
    'insertdatetime media table contextmenu paste code help'
  toolbar: 'insert | undo redo |  formatselect | bold italic backcolor  | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',
  content_css: [

there isn't any good validation tutorial on it's official website, so how can i validate tinyMCE ?

Asked by:- Sam
: 6898 At:- 12/15/2017 8:11:47 AM
MVC tinyMCE-validate-in-razor validation razor

1 Answers
profileImage Answered by:- bhanu

You can validate TinyMCE using jQuery validate plugin, it is quite helpful plugin, widely used and  easier to use.

Here is how you can validate TinyMCE using jQuery validate plugin

TinyMCE jQuery code

      selector: 'textarea',
      theme: "modern",
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "save table contextmenu directionality emoticons template paste textcolor"
       content_css: "css/content.css",
       toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
         setup: function (ed) {
                 //On change call
                   ed.on('change', function (e) {
                           //Validate tinyMCE on text change
                               $("#" +;




<form id="myform" url="/">
    <textarea name="content"></textarea>
    <input type="submit" value="Submit" />

jQuery validate part

$(function() {
//initialize validatoe
		var validator = $("#myform").submit(function() {

			// update underlying textarea before submit validation
		})//validation rules
			ignore: "",
			rules: {
				content: "required"
			errorPlacement: function(label, element) {
				// position error label after generated textarea
				if ("textarea")) {
				} else {

		validator.focusInvalid = function() {
			// put focus on tinymce on submit validation
			if (this.settings.focusInvalid) {
				try {
					var toFocus = $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []);
					if ("textarea")) {
					} else {
				} catch (e) {
					// ignore IE throwing errors when focusing hidden elements

here is the complete working fiddle

If you didn't liked the above plugin you can also try form.validation which is also another jQuery form validation plugin, and the link demostrate validating tinyMCE using it

At:- 12/17/2017 6:01:47 PM Updated at:- 12/17/2017 6:02:22 PM
Works well and as needed, fiddle link is always quite helpful to check the working status of code :) 0
By : Sam - at :- 12/19/2017 12:49:55 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use