2015-05-06 22 views
0

我已經集成了bootstrap-wysihtml5編輯器來描述部分在我的Rails應用程序。現在我想添加客戶端驗證,以便驗證描述字段的存在。我用bootstrap-wysihtml5-rails寶石。提前如何添加前端驗證在引導-wysihtml5護欄

<script type="text/javascript"> 
$(document).ready(function(){ 

    $('#description').each(function(i, elem) { 
     $(elem).wysihtml5({ 
      toolbar: { 
       "fa": true, // use Font Awesome 
       "font-styles": false, // Font styling, e.g. h1, h2, etc. 
       "emphasis": true, // Italics, bold, etc. 
       "lists": false, // (Un)ordered lists, e.g. Bullets, Numbers. 
       "html": false, // Button which allows you to edit the generated HTML. 
       "link": true, // Button to insert a link. 
       "image": true, // Button to insert an image. 
       "color": false, // Button to change color of font 
       "blockquote": false // Blockquote 
      } 
     }); 
    }); 

}) 

感謝:

編輯器正在初始化與下面的代碼。

+0

的建議,如果你想只使用最大和最小count..you可以使用HTML ... – Milind

+0

提供的默認maxlenght和minlenght對不起找到了解決辦法,但那不適合我。 – SujitS

+0

你可以嘗試jquery.validate js,並在你想要的任何字段上設置驗證....參考http://jqueryvalidation.org/documentation/ – Milind

回答

0

通過添加事件被documentation

$('#some-textarea').wysihtml5({ 
    "events": { 
     "load": function() { 
      console.log("Loaded!"); 
     }, 
     "blur": function() { 
      console.log("Blured"); 
     } 
    } 
});