【问题标题】:Validating nicedit form textarea验证nicedit表单文本区域
【发布时间】:2014-07-19 21:40:24
【问题描述】:

我有一个由 Nicedit 转换为富文本编辑器的表单。此外,我已将 Jquery 验证插件应用于表单,除 textarea 标记外,一切正常。 textarea 标签没有响应 jquery 验证插件。当我点击提交按钮而不在文本区域中输入文本时,表单被提交。如果有人可以帮助我,我会很高兴。 以下是我的代码:

<!DOCTYPE html>
<head>
<script src="nicEdit.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style>
body
{
font-family:Gotham,'sans-serif';
}

    </style>
    </body>
    </head>
    <body>
    <form id="ruebenform" novalidate="novalidate">
    Firstname: <input name="firstname" id="firstname">
    <textarea id="thetextarea" rows="5" cols="45"></textarea>
            <button type="submit">Submit</button>
    </form>

    <script type="text/javascript">
        new nicEditor({maxHeight : 50}).panelInstance('thetextarea');
    </script>

    //Jquery validation script
  <script>
    $("#ruebenform").validate({
                rules:{
                         firstname: {
                                 required: true,
                                 minlength: 2
                         },
                         thetextarea: {
                                 required: true,
                                 minlength: 2
                         }
                 },
                 messages: {
                         firstname: {
                                 required: "Please enter a title",
                                 minlength: "At least 2 characters"
                         },
                         thetextarea: {
                                 required: "Please enter a description",
                                 minlength: "At least 2 characters"
                         }
                 },
                 submitHandler: function(form) { return false; }
         });
    </script>
 </body>
 </html>

【问题讨论】:

    标签: jquery html css jquery-plugins


    【解决方案1】:

    您需要将 ID 放入 textarea。然后用 jQuery 调用它,检查长度并应用 css 规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-04
      • 1970-01-01
      • 1970-01-01
      • 2020-01-19
      • 1970-01-01
      • 2011-03-02
      相关资源
      最近更新 更多