How to check if a text is all white space characters in client side?

后端 未结 11 1144
心在旅途
心在旅途 2020-12-23 11:14

How to check if a user input text is all white space characters (space, tab, enter etc) in client side?

11条回答
  •  [愿得一人]
    2020-12-23 11:48

    To find whitespace generated by JavaScript and between elements use:

    var trimmed = $.trim( $('p').text() );
    
    if ( trimmed === '' ){
        //function...
    }
    

提交回复
热议问题