Using TINYMce and validation, but it takes to two times to post and it doesn't matter whether the textarea is empty or not. I research this but wasn't able to find anything that worked. Below is code snippets.
Model
[Required(ErrorMessage = "*Response Required")]
[UIHint("tinymce_jquery_full"), AllowHtml]
public string LibrarianResponse { get; set; }
View
<span style="color: red;font-weight: 700;">@Html.ValidationMessageFor(m => m.LibrarianResponse)</span>
<div class="editor-field">
@Html.EditorFor(model => model.LibrarianResponse)
</div>
<script type="text/javascript">
jQuery(function ($) {
$('#submit').click(function () {
tinyMCE.triggerSave();});
});
</script>
<input type="submit" value="Submit" />
Thank in advance.
It takes a small amount of time for TinyMCE to update the original (now hidden) inputs it operates on top of. You are doing that with
triggerSave
. However, the form submit is likely going to continue and run beforetriggerSave
finishes. So do this: