ASP.Net MVC 5 CKEditor AllowHtml RequiredAttribute不工作

时间:2017-11-06 05:04:48

标签: asp.net-mvc validation

我在我的模型中使用AllowHtml for CKeditor,我也分配了必填字段,但验证不起作用,我的模型如下: -

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

1 个答案:

答案 0 :(得分:0)

<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>