js判断fck编辑器内容是否为空并获得焦点

本文介绍了一个使用FCKeditor的留言验证脚本,该脚本确保用户在提交留言前已填写了必要的信息,如称呼和留言内容。如果这些字段为空,则会提示用户进行填写。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


 
01 <script type="text/javascript" language="javascript">
02 function confirm()
03 {
04 var textname=document.getElementById("ctl00_ContentPlaceHolder1_TxtName").value;
05 if(textname=="")
06 {
07 alert("您还是留个称呼吧!");
08 document.getElementById("ctl00_ContentPlaceHolder1_TxtName").focus();
09 return false;
10 }
11 return getContentValue();
12 }
13 function getContentValue()
14 {
15 var oEditor =FCKeditorAPI.GetInstance("ctl00_ContentPlaceHolder1_FCKeditor1");
16 var Content=oEditor.GetXHTML();
17 if(Content=="")
18 {
19 alert("您还没有写留言哦!");
20 oEditor.Focus();//获取焦点
21 return false;
22 }
23 }
24 </script>

注意:

其中的"ctl00_ContentPlaceHolder1_FCKeditor1"是生成的静态页面中的FCK的实例名称

src="/Web/fckeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_FCKeditor1&amp;

1 <td style="vertical-align:top; text-align:right;">留言内容:</td><td><div><input type="hidden" id="ctl00_ContentPlaceHolder1_FCKeditor1" name="ctl00$ContentPlaceHolder1$FCKeditor1" value="" /><input type="hidden" id="ctl00_ContentPlaceHolder1_FCKeditor1___Config" value="HtmlEncodeOutput=true" /><iframe id="ctl00_ContentPlaceHolder1_FCKeditor1___Frame" src="/Web/fckeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_FCKeditor1&amp;Toolbar=Standard" width="90%" height="150px" frameborder="no" scrolling="no"></iframe></div></td>

转载于:https://www.cnblogs.com/jianfangkk/archive/2008/12/10/1367162.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值