首页 \ 问答 \ 如何检查textarea(tinymce)是否只包含空格?(How can I check if textarea (tinymce) only contains space?)

如何检查textarea(tinymce)是否只包含空格?(How can I check if textarea (tinymce) only contains space?)

我有一个使用Tinymce的表单,我需要检查它是否只包含空格。

我尝试使用这个功能

function validation_form()
{
    var content = tinyMCE.get('main-comment').getContent().replace(' ','');
    if(content == "" || content == null || content == '<p> </p>') {
        return false;
    }
}

但是当我输入几个空格并提交时,它返回true ,我希望它返回false。

谁能帮我? 谢谢,


I have a form using Tinymce, I need to check if it only contains space.

I try using this function

function validation_form()
{
    var content = tinyMCE.get('main-comment').getContent().replace('&nbsp;','');
    if(content == "" || content == null || content == '<p> </p>') {
        return false;
    }
}

But it returns true when I input several spaces and submit, I want it to return false instead.

Can anyone help me? Thanks,


原文:https://stackoverflow.com/questions/38067154
更新时间:2022-03-31 13:03

最满意答案

你定义你的表的方式,你的CSS应该是这样的

#divMyList tbody tr td{
    cursor:pointer;
    border-right:5px solid white;
    padding:10px;
    width:200px;
}

.topmenu {
    width: 100%;
    height: 40px;
    font-size: 14px;
    font-weight: normal;
}

.topmenu td.selected{
    cursor: default!important;
}

我已经把一个小提琴放在一起并添加了一种颜色来表明它的样式


the way you have defined your table, your css should look like this

#divMyList tbody tr td{
    cursor:pointer;
    border-right:5px solid white;
    padding:10px;
    width:200px;
}

.topmenu {
    width: 100%;
    height: 40px;
    font-size: 14px;
    font-weight: normal;
}

.topmenu td.selected{
    cursor: default!important;
}

I have put together a fiddle and added a color to show that it is getting styled

相关问答

更多
  • 不,IE从来不支持任何财产inherit - 对不起。 这已经在> = IE8中修复。 虽然您可以使用JavaScript修复程序将属性从h2复制到a ,但对两个元素应用相同的样式规则可能最简单: h2, h2 a { font: something; color: black; text-decoration: none; } 无论如何,您不需要在文本修饰上设置inherit ,因为装饰不会从父项继承到子项中:下划线效果在父项上,并通过子项; 孩子不能删除它(模块IE错误)。 对 ...
  • 你定义你的表的方式,你的CSS应该是这样的 #divMyList tbody tr td{ cursor:pointer; border-right:5px solid white; padding:10px; width:200px; } .topmenu { width: 100%; height: 40px; font-size: 14px; font-weight: normal; } .topmenu td.selected{ ...
  • 在同一页面下方: “角色属性LOGIN,SUPERUSER,CREATEDB和CREATEROLE可以被认为是特殊权限,但是它们不会像数据库对象的普通特权那样被继承,你必须实际上将ROLE设置为具有这些特性之一的特定角色,以便利用这个属性。“ A bit further down the same page: "The role attributes LOGIN, SUPERUSER, CREATEDB, and CREATEROLE can be thought of as special privile ...
  • 在下面添加到上下文文件: 需要激活已在应用程序上下文中注册的bean中的注释 Add below to context file: is required to activate annotations in beans already registered in the application context
  • 继承建议是垃圾,你应该组成时钟(微波炉可能包含一个时钟,因为你的微波类已经写好),所以从你的Clock类中删除extends Microwave 。 除非这个问题,另一个问题是你的CTOR: Microwave() { maxPower = 500; currentPower = 500; theClock = new Clock(); } Microwave(int maxp, Clock theClock) { maxPower = maxp; currentP ...
  • 您不应该在CSS中使用HTML元素名称前面的点。 另外,你的div有类.title-in-green ,而不是h1 ,所以把你的:not放在div上。 但是,对于您的具体情况,使用:not必要,因为您希望异常是.title-in-green类。 小提琴: https : //jsfiddle.net/ahddxw2x/ HTML

    my title

    my title

    ...
  • 我能想到的只有两个可能的原因: 您的视图仍在尝试渲染base.html而不是您继承的html模板。 只需更改视图即可调用正确的视图( version_tag.html ) 您真正尝试显示的模板仍然继承自base.html而非version_tag.html There are only two possible causes I can think of: Your view is still trying to render base.html instead of your inherited html ...
  • 在使用超级构造函数时,您不需要并且实际上不应该设置父字段,因为super(...)构造函数调用将为您执行此操作。 public Car(String make, String model, String colour, int registrationNumber) { super(make, model, colour, registrationNumber); // get rid of these: // this.make = make; // this.mode ...
  • 更改位置:绝对位置:div.job类的相对位置 Change position:absolute to position:relative for div.job class
  • 我认为你需要有相同的函数签名,所以传递string $tableName : class CreateItemsTable extends BaseMigration { public function up(string $tableName) { Schema::create('items', function (Blueprint $table) { parent::up('items'); $table->string('name' ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)