我正在尝试使用JavaScript进行验证,如果fckeditor值为空或不是,但没有运气。
我正在使用javascript创建编辑器:
var oFCKeditor = new FCKeditor('txtMessage');
oFCKeditor.BasePath = "../fckeditor/";
oFCKeditor.ToolbarSet = "Default";
oFCKeditor.Height = "500";
oFCKeditor.Value = "test";
oFCKeditor.Create();
但是当我使用时:
if (document.form.txtMessage.value == "") {
alert('You Must Enter a Message');
当编辑器为空并提醒我并在其中写入内容时,它会一直警告它是空的。
答案 0 :(得分:2)
点击这里
<script type="text/javascript">
function checksubmit() {
var FCKGetInstance = FCKeditorAPI.GetInstance('PageDescription');
var getText = FCKGetInstance.GetData();
var StripTag = getText.replace(/(<([^>]+)>)/ig,"");
if(StripTag=='') {
alert("This is required field");
return false;
}
else {
alert(StripTag);
}
}
</script>
<input type="submit" name="submit" value="submit" onclick="javascript: return checksubmit();" />