2013-08-01 2 views
0

나는 aspx apge (.net)에 tinymce 서식있는 텍스트 편집기가 있는데, 이것에 클라이언트 측 유효성 검사를 적용하고 싶다. 아무도 나를 도울 수 있습니까?서식있는 텍스트 편집기에서 클라이언트 측 유효성 검사를 적용하는 방법은 무엇입니까?

+0

당신이 텍스트 영역에 유효성 검사를 추가하려고 않았다 해결 될 수 있습니다 희망 버튼 클릭 이벤트

$("#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(); } }); 

을 jQuery를 만들기에 제출? (btw 나는 프로젝트에서 ckEditor 선호) – Arda

+0

"alert (document.getElementById ('<% = txt_editor1.ClientID %>'). value);"로 텍스트 영역의 값을 가져 오려고했습니다. 그러나 그것은 나에게 빈 경보를 보여줍니다. 무엇이 문제의 가능한 원인 일 수 있습니까? –

+0

시도 tinyMCE.get ('<% = txt_editor1.ClientID %>'). getContent 또는 tinyMCE.activeEditor.getContent – Arda

답변

0

document.getElementById('<%=txt_editor1.ClientID %>').value 대신 tinyMCE.get('<%=txt_editor1.ClientID %>').getContent()을 사용해야하므로 이렇게 할 수 있습니다. 당신이 필요한 검증 TinyMCE에 HTML 편집기가 확인 작동하지 않는 경우

function valid(){ 
    var content = tinyMCE.get('<%=txt_editor1.ClientID %>').getContent(); 
    if(content.length>100){ 
    return false; 
    } 
    return true; 


} 
0

, 당신의 경로를 제공 모델에서 응용 프로그램에서

를 TinyMCE를 설치, 문제를 해결하기 위해
를이 코드를 사용할 수 있습니다 확인 tinymce.cshtml 페이지

[Required(ErrorMessage = "Please enter About Company")] [Display(Name = "About Company : ")] [UIHint("tinymce_jquery_full"), AllowHtml] public string txtAboutCompany { get; set; } 

이제보기에이

,536처럼 하나 개의 범위를 추가
<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> 

내가 문제가