【问题标题】:ASP.Net MVC 5 CKEditor AllowHtml RequiredAttribute Not workingASP.Net MVC 5 CKEditor AllowHtml RequiredAttribute 不工作
【发布时间】:2017-11-10 17:59:16
【问题描述】:

我在我的模型中为 CKeditor 使用 AllowHtml,并且我还分配了必填字段,但验证不起作用,我的模型就像:-

    [Display(Name = "Introduction Details:")]
    [Required(ErrorMessage = "Introduction Details is required.")]
    [AllowHtml]
    public string Introduction { get; set; }   

【问题讨论】:

标签: asp.net-mvc validation


【解决方案1】:
<script type="text/javascript">
    $(document).ready(function () {
        $('#CkEditor1').ckeditor();
        $('#Testimonials_error').hide();

    });
    function GetCKEditorData() {
        var data = $('#CkEditor1').val();
        if (data != "") {
            var c = confirm("Do you want to save this record");
            if (c) {
                window.location.href = "/Admin/Testimonials";
            }
        }
        else {
            $('#Testimonials_error').show();
            return false;
        }
    }
</script>

【讨论】:

  • 在表单点击事件上使用 OnBegin 方法 (OnBegin = "return GetCKEditorData()")
猜你喜欢
  • 1970-01-01
  • 2017-01-12
  • 2018-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-20
  • 2017-06-30
  • 1970-01-01
相关资源
最近更新 更多