TinyMCE的客户端验证问题 [英] TinyMCE client validation problem

查看:177
本文介绍了TinyMCE的客户端验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TinyMCE的编辑器的问题。我很少文本字段和文本区域(TinyMCE的),并启用客户端验证方式。当我点击保存按钮确认occures上的所有文本字段,但它需要2点击验证TinyMCE的内容。此外,验证消息显示,只有当字段为空,或者如果条件不满足(只是为了测试的原因,可以输入最多5个字符),但是当我输入的字符数权(小于5),错误信息停留。

I have problem with TinyMCE editor. I have form with few text fields and textarea (tinymce), and enabled client validation. When I click save button validation occures on all text fields, but it takes 2 click to validate tinymce content. Furthermore, validation shows message only when field is empty, or if condition is not satisfied (just for test causes, max 5 characters can be entered), but when I enter right number of characters ( less then 5 ), error message stays.

下面是code样品:<​​/ P>

Here's code sample:

    <%Html.EnableClientValidation(); %>
    <%= Html.ValidationSummary(true, "Na stranici postoje greške.", new { @style = "color: red;" })%></p>
    <% using (Html.BeginForm("Create", "Article", FormMethod.Post, new { enctype = "multipart/form-data" }))
       { %>
    <fieldset>
        <legend>Podaci za Aranžman</legend>
            <label class="EditLabel" for="name">
                Opis</label>
            <br />
            <%= Html.TextAreaFor(Model => Model.Description, new { style = "width: 100%; height: 350px;", @class = "tinymce" })%>
            <%= Html.ValidationMessageFor(Model => Model.Description, "", new { @style = "color: red;" })%>
        <p>
            <input type="submit" value="Sačuvaj aranžman" />
        </p>
    </fieldset>
    <% } %>

和属性

    [Required(ErrorMessage = "Unesi opis")]
    [StringLength(5, ErrorMessage = "Opis mora imati manje od 5 znakova")]
    public string Description { get; set; }

任何建议???

Any suggestions???

推荐答案

这背后的原因是,大多数富文本编辑器(包括微小的MCE)不使用文本区域。相反,它拥有文字它自己的输入,只复制提交表单时。所以,您要验证字段,当你键入编辑器的东西实际上并不改变。

The reason behind this is that most rich text editors (including tiny mce) doesn't use the text area. Instead it has it's own input and only copies over the text when the form is submitted. So the field you are validating doesn't actually change when you type something in the editor.

你将要做的是创建工作围绕这个那份从编辑到文本区域中的文本,当你点击提交按钮。这可以这样进行:

What you will have to do is create a work around for this that copies the text from the editor to the text area when you click the submit button. This can be done like this:

$('#mySubmitButton').click(function() {
    tinyMCE.triggerSave();
});

这篇关于TinyMCE的客户端验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆