2016-04-15 15 views
0

wysihtml5対応のtextarea要素に対して、入力としてのみ空白のみの検証を追加する必要があります。テキストボックスのwysihtml5エディタを入力として空白のみを妥当性検査

  1. 私はテキストエリアのコンソールにのみスペースを入力する値は次の通りです:

    &nbsp;&nbsp; <br> 
    
  2. が動作していない私の検証ルールは次のとおりです。

    if (!$.trim(<textarea value>)) { 
         // textarea is empty or contains only white-space 
         toastr.error("You forgot to write your answer body, kindly write some thing in answer box.");    
         return false; 
        } 
    
  3. 私はいずれかを取得していません空白のみの入力値を検証するwysihtml5オプション

    $('#some-textarea').wysihtml5({ 
    "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true 
    "emphasis": true, //Italics, bold, etc. Default true 
    "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true 
    "html": false, //Button which allows you to edit the generated HTML. Default false 
    "link": true, //Button to insert a link. Default true 
    "image": true, //Button to insert an image. Default true, 
    "color": false //Button to change color of font 
    }); 
    

答えて

0

私は次のようにそれを成し遂げるために管理:将来、このような要件については

var name = $("#textAreaInput").val(); #&nbsp;&nbsp; <br> 
var n = name.replace(/ /g,''); 
var c = n.replace(/^(&nbsp;)+/g, ''); 
var f = c.replace(/^(<br>)+/g, ''); 
if (f.length==0) { 
    toastr.error("Display error"); 
    return false; 
} 

おかげ

+0

           その後、このテキストを検証する方法                  Rhushikesh

0

、次のようにエディタの値を取得することをお勧めします:

var name = $("#textAreaInput").data('wysihtml5').editor.getValue(); 

var validateWysi = name.replace(/ /g,'').replace(/^(&nbsp;)+/g, '').replace(/^(<br>)+/g, '').replace(/^(<br\/>)+/g, ''); 

if(validateWysi.length==0) 
{ 

toastr.error("Display error"); 

return false; 

} 
関連する問題