我有一個MVC3 C#.Net Web App。我們正在使用ckEditor庫來增強我們應用中的TextAreas。使用標準TextArea時,驗證操作正確。但是,在增強的TextAreas(實現ckEditor)中,提交頁面時,驗證會觸發錯誤。即使TextArea中存在數據,「描述是必需的」。第二次點擊提交後,表單提交正常。MVC3 C#TextArea/CkEditor驗證問題
域類屬性:
[Display(Name = "Description")]
[Required(ErrorMessage = "Description is required.")]
public virtual string Description { get; set; }
HTML:
<td style="border: 0;text-align:left " >
@Html.TextAreaFor(model => model.Description,
new
{
rows = 5,
cols = 100,
@class = "celltext2 save-alert"
})
@Html.ValidationMessageFor(model => model.Description)
</td>
我認爲應用CKEDITOR屬性以某種方式搞亂起來。想法?`
讓我澄清更多。我們有一個查詢控件的.js文件,然後執行ckEditor初始化。當我刪除$(this).ckeditor({})
它工作正常。
JS文件:
$('textarea').each(function() {
$(this).ckeditor({});
});
@Dave ...我喜歡這個主意。儘管如此,仍然沒有奏效。我在考慮.ckeditor初始化正在做一些事情,讓textarea感到困惑 – MikeTWebb
更新了我的答案。 – Dave
@戴夫..感謝。我會檢查出來的 – MikeTWebb