F你有HTML編輯器TinyMCE的要求的驗證工作不正常,你可以用這個代碼來解決你的問題, 在你的應用程序中安裝tinymce 如果你有多個Htmleditor,你可以這樣做 我知道這是正確的解決方案,但你可以做到這一點,並解決這個問題o
在模型中給出tinymce的路徑。CSHTML頁確定
[Required(ErrorMessage = "Please enter About Company")]
[Display(Name = "About Company : ")]
[UIHint("tinymce_jquery_full"), AllowHtml]
public string txtAboutCompany { get; set; }
[Required(ErrorMessage = "Please enter About Company")]
[Display(Name = "About Company : ")]
[UIHint("tinymce_jquery_full"), AllowHtml]
public string txtAboutCompany { get; set; }
現在,在您的視圖中添加一個跨度這樣
<div class="divclass">
@Html.LabelFor(model => model.txtAboutCompany, new { @class = "required" })
@Html.EditorFor(model => model.txtAboutCompany)
<span class="field-validation-error" id="AC" style="margin:9px 0 0 157px;"></span>
</div>
<div class="divclass">
@Html.LabelFor(model => model.txtAboutCompany, new { @class = "required" })
@Html.EditorFor(model => model.txtAboutCompany)
<span class="field-validation-error" id="AC" style="margin:9px 0 0 157px;"></span>
</div>
創建的jQuery的提交按鈕點擊事件
$("#BusinessProfile").click(function() {
var aboutC = $("#txtAboutCompany").val()
var pinfo = $("#txtProductinfo").val();
if (aboutC == "" && pinfo == "") {
$("#AC").append("").val("").html("Please enter about company")
$("#PI").append("").val("").html("Please enter product information")
$("#bpform").valid();
return false;
} else if (aboutC == "") {
$("#PI").append("").val("").html("")
$("#AC").append("").val("").html("Please enter about company")
$("#txtAboutCompany").focus();
$("#bpform").valid();
return false;
} else if (pinfo == "") {
$("#AC").append("").val("").html("")
$("#PI").append("").val("").html("Please enter product information")
$("#txtProductinfo").focus();
$("#bpform").valid();
return false;
}
else {
$("#AC").append("").val("").html("");
$("#PI").append("").val("").html("");
//return true;
$("#bpform").validate();
}
});
我希望你的問題可能是解決
這是我在找什麼..但在此代碼也將每個編輯器的內容放入'description'中,我們可以以某種方式獲得相應的textarea的id,以便我們將編輯器中的內容放到相應的textarea中。 – uttam 2012-04-25 10:01:33
使用tinymce.editors [i] .id – Thariama 2012-04-25 10:13:21
可以得到編輯器的id(它們等於textarea ID),以便將編輯器的內容放到相應的textarea中,也可以使用tinymce.triggerSave()一次爲所有的tinymce編輯器執行此操作! – Thariama 2012-04-25 10:14:40