我正在尝试使用 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');
当编辑器为空并提醒我并且我在其中写入内容时,它会一直提醒它为空。
最佳答案
检查这里
<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();" />
关于php - 验证FCKEditor是否为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10596884/