• <legend id='kRX0I'><style id='kRX0I'><dir id='kRX0I'><q id='kRX0I'></q></dir></style></legend>

        <bdo id='kRX0I'></bdo><ul id='kRX0I'></ul>

    1. <tfoot id='kRX0I'></tfoot>
      1. <small id='kRX0I'></small><noframes id='kRX0I'>

        <i id='kRX0I'><tr id='kRX0I'><dt id='kRX0I'><q id='kRX0I'><span id='kRX0I'><b id='kRX0I'><form id='kRX0I'><ins id='kRX0I'></ins><ul id='kRX0I'></ul><sub id='kRX0I'></sub></form><legend id='kRX0I'></legend><bdo id='kRX0I'><pre id='kRX0I'><center id='kRX0I'></center></pre></bdo></b><th id='kRX0I'></th></span></q></dt></tr></i><div id='kRX0I'><tfoot id='kRX0I'></tfoot><dl id='kRX0I'><fieldset id='kRX0I'></fieldset></dl></div>

        有没有办法在 wp_editor 函数中应用字符限制?

        时间:2023-09-06
            <tbody id='tqe17'></tbody>

                  <bdo id='tqe17'></bdo><ul id='tqe17'></ul>

                  <tfoot id='tqe17'></tfoot>
                  <legend id='tqe17'><style id='tqe17'><dir id='tqe17'><q id='tqe17'></q></dir></style></legend>
                  <i id='tqe17'><tr id='tqe17'><dt id='tqe17'><q id='tqe17'><span id='tqe17'><b id='tqe17'><form id='tqe17'><ins id='tqe17'></ins><ul id='tqe17'></ul><sub id='tqe17'></sub></form><legend id='tqe17'></legend><bdo id='tqe17'><pre id='tqe17'><center id='tqe17'></center></pre></bdo></b><th id='tqe17'></th></span></q></dt></tr></i><div id='tqe17'><tfoot id='tqe17'></tfoot><dl id='tqe17'><fieldset id='tqe17'></fieldset></dl></div>

                • <small id='tqe17'></small><noframes id='tqe17'>

                • 本文介绍了有没有办法在 wp_editor 函数中应用字符限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试找出如何在前端提交表单的资源框中组合此代码,但我需要将其限制为一定数量的字符.

                  I am trying to find out how to combine this code in resource box on a front end submission form but I need it to be limited to a certain number of characters.

                  <?php wp_editor( get_option('resource'), 'resource', array('textarea_name' => 'resource', 'class'=>'requiredField', 'textarea_rows'=>'6','id'=>'resource' ,'onkeyup'=>'countChar(this)','media_buttons' => false)  );?><?php if(isset($_POST['resource'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['resource']); } else { echo $_POST['resource']; } } ?>
                  

                  此代码检查该字段是否为空:

                  This code checks if the field is empty:

                  <?php if(isset($_POST['resource'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['resource']); } else { echo $_POST['resource']; } } ?>
                  

                  如何在 wp_editor 函数中进行检查?我需要这个来允许和简化我的资源框中的 html 给用户...

                  How can I make that check inside wp_editor function? I need this to allow and simplify html inside my resource box to users...

                  这是我在里面使用的 javascript 函数 ('onkeyup'=>'countChar(this)') 但它不起作用.

                  This is the javascript function that I am using ('onkeyup'=>'countChar(this)') inside but it's not working.

                  我在这儿摔倒了吗?

                  推荐答案

                  我根据自己的需要稍微修改了 Bryan Gentry 的解决方案,它运行良好.如果您需要类似的功能,这是我的代码.

                  I altered Bryan Gentry's solution a tiny bit to my needs and it works nicely. Here is my code if you need a similar functionality.

                  add_filter( 'tiny_mce_before_init', 'wpse24113_tiny_mce_before_init' );
                  function wpse24113_tiny_mce_before_init( $initArray )
                  {
                      $initArray['setup'] = <<<JS
                  [function(ed) {
                      ed.onKeyDown.add(function(ed, e) {
                          if(tinyMCE.activeEditor.editorId=='content-id') {
                              var content = tinyMCE.activeEditor.getContent();
                              var max = 300;
                              var len = content.length;
                              if (len >= max) {
                                $('#charNum').html('<span class="text-error">You've got more then '+max+' characters!</span>');
                              } else {
                               var charCount = max - len;
                               $('#charNum').html(charCount + ' characters left');
                              }
                           }
                      });
                  
                  }][0]
                  JS;
                      return $initArray;
                  }
                  

                  这篇关于有没有办法在 wp_editor 函数中应用字符限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么 React Fibre 会多次调用 componentWillMount? 下一篇:Ember.js Application.inject 循环依赖

                  相关文章

                    <i id='yuxcm'><tr id='yuxcm'><dt id='yuxcm'><q id='yuxcm'><span id='yuxcm'><b id='yuxcm'><form id='yuxcm'><ins id='yuxcm'></ins><ul id='yuxcm'></ul><sub id='yuxcm'></sub></form><legend id='yuxcm'></legend><bdo id='yuxcm'><pre id='yuxcm'><center id='yuxcm'></center></pre></bdo></b><th id='yuxcm'></th></span></q></dt></tr></i><div id='yuxcm'><tfoot id='yuxcm'></tfoot><dl id='yuxcm'><fieldset id='yuxcm'></fieldset></dl></div>
                  1. <small id='yuxcm'></small><noframes id='yuxcm'>

                  2. <tfoot id='yuxcm'></tfoot>

                    <legend id='yuxcm'><style id='yuxcm'><dir id='yuxcm'><q id='yuxcm'></q></dir></style></legend>
                    • <bdo id='yuxcm'></bdo><ul id='yuxcm'></ul>