How can I check if textarea (tinymce) only contains space?

Henry Bui

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(' ','');
    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,

A.T.

use $.trim ,

it is clean and readable.

function validation_form()
{
    var content = $.trim(tinyMCE.get('main-comment').getContent({format: 'text'}));
    if(content.length == 0) {
        return false;
    }
   return true;
}

Updated: format as text, to get text content from editor. check fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I check if a QString contains only "invisible" characters?

From Dev

How can I check whether is a string contains only English letters?

From Dev

How can i check of a string contains a letter space letter space and anotherl letter C#

From Dev

How can i check if $varA contains $varB?

From Dev

How can I check if a dictionary contains a dictionary?

From Dev

How can I check if a string contains only numbers, comma and periods with regex in javascript?

From Dev

How can I check if a string contains only a particular set of special characters in Javascript?

From Dev

PHP - How can I check if a string contains only lower case characters?

From Dev

How can I check the JTextField only contains upper and lower case letters and '-' using regex

From Dev

How can I use all td space with a textarea?

From Dev

How can I send tinyMCE textarea editor content to inside controller using Symfony3 and Ajax

From Dev

How do I check if int[] contains only certain numbers?

From Dev

How to I check that a string contains only digits and / in python?

From Dev

how can i make textarea a read only but will not be greyed out

From Dev

How can I check how much space specific packages occupy?

From Dev

Pandas: How can I check if a pandas dataframe contains a specific value?

From Dev

In R, how can I check whether a list contains a particular key?

From Dev

How can I check if a file contains a string or a variable in JavaScript?

From Dev

Bitwise - How can I check if a binary number contains another?

From Dev

How can I check if an ArrayList contains any element of another ArrayList?

From Dev

How can I check if a string contains Chinese in Swift?

From Dev

How can I check if a cell in Excel spreadsheet contains number

From Dev

How can I check if a HashSet contains an item using the hash of the item?

From Dev

How can I check If a nested array contains a value?

From Dev

How can I check if a string contains letters in Swift?

From Dev

Javascript: How can i check if a array contains certain values

From Dev

How can I check if the string contains certain word?

From Dev

How can I check if javascript array already contains a specific array

From Dev

How can I check if a string contains an hexadecimal value in VBScript?

Related Related

  1. 1

    How can I check if a QString contains only "invisible" characters?

  2. 2

    How can I check whether is a string contains only English letters?

  3. 3

    How can i check of a string contains a letter space letter space and anotherl letter C#

  4. 4

    How can i check if $varA contains $varB?

  5. 5

    How can I check if a dictionary contains a dictionary?

  6. 6

    How can I check if a string contains only numbers, comma and periods with regex in javascript?

  7. 7

    How can I check if a string contains only a particular set of special characters in Javascript?

  8. 8

    PHP - How can I check if a string contains only lower case characters?

  9. 9

    How can I check the JTextField only contains upper and lower case letters and '-' using regex

  10. 10

    How can I use all td space with a textarea?

  11. 11

    How can I send tinyMCE textarea editor content to inside controller using Symfony3 and Ajax

  12. 12

    How do I check if int[] contains only certain numbers?

  13. 13

    How to I check that a string contains only digits and / in python?

  14. 14

    how can i make textarea a read only but will not be greyed out

  15. 15

    How can I check how much space specific packages occupy?

  16. 16

    Pandas: How can I check if a pandas dataframe contains a specific value?

  17. 17

    In R, how can I check whether a list contains a particular key?

  18. 18

    How can I check if a file contains a string or a variable in JavaScript?

  19. 19

    Bitwise - How can I check if a binary number contains another?

  20. 20

    How can I check if an ArrayList contains any element of another ArrayList?

  21. 21

    How can I check if a string contains Chinese in Swift?

  22. 22

    How can I check if a cell in Excel spreadsheet contains number

  23. 23

    How can I check if a HashSet contains an item using the hash of the item?

  24. 24

    How can I check If a nested array contains a value?

  25. 25

    How can I check if a string contains letters in Swift?

  26. 26

    Javascript: How can i check if a array contains certain values

  27. 27

    How can I check if the string contains certain word?

  28. 28

    How can I check if javascript array already contains a specific array

  29. 29

    How can I check if a string contains an hexadecimal value in VBScript?

HotTag

Archive