惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 从无到有.NET

[转帖]如何提升JavaScript操作DOM的效率 揭开正则表达式的神秘面纱 比较完整的一个 Ajax 类库汇总 解决“未能创建 Mutex”的问题 解决ASP.NET的进程帐户没有访问IIS的权限 MSN Messenger去广告和其他修改方法 - 从无到有.NET - 博客园 如何取消“本页不但包含安全的内容,也包含不安全的内容。是否显示不安全的内容。” 的提示 【转贴】datagrid数据导出到excel文件给客户端下载的几种方法 ASP.NET 中的正则表达式 asp.net TreeView安装、使用(如何将TreeView打包发布)(带CheckBox选择框的TreeView的初始化,TreeView客户端操作:选择父节点后自动选择所有子节点,子节点选择后自动选择父节点)(TreeView节点精确定位) 使用C#调用外部Ping命令获取网络连接情况 在.Net中嵌入资源文件到程序集中 RegularExpressionValidator 【原创】如何去掉有源代码管理的项目中的相关信息 关于PHP--session的问题集锦解决方案 php和asp对象的等价关系 My SQL出错代码及出错信息对照 Windows 环境下的 PHP5 与 Apache 服务器的配置 - 从无到有.NET php.ini中文解释
FCKEditor使用RequiredFieldValidator验证时必须点击两次的解决办法
从无到有.NET · 2006-10-19 · via 博客园 - 从无到有.NET

FCKEditor是一个很不错的在线编辑器,可称得上完美,但是它有一个问题,就是在使用RequiredFieldValidator进行验证的时候,即使内容不为空,也需要点击两次才能完成,经过查找网上的资料,发现好像是它本身的一个问题,原文如下:

With ASP.Net, I need to submit twice when using the RequiredFieldValidator in a FCKeditor instance

FCKeditor will not work properly with the Required Field Validator when the "EnableClientScript" property of the validator is set to "true" (default). Due to a limitation in the default validation system, you must set it to "false".

If you want to do client side validation, you must use a Custom Validator instead and provide the appropriate validation function, using the FCKeditor JavaScript API.

译文如下(翻译的不好,大家能看懂就好):
问:为什么在使用ASP.NET的RequiredFieldValidator时,我需要提交两次
答:当RequiredFieldValidator的EnableClientScript属性被设置成true时,FCKEditor不能很好的支持RequiredFieldValidator,为了解除这个限制,你必须把这个属性设置成为false
如果你希望使用客户端验证,你必须使用Custom Validator制作一个非空验证来替换RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。

看了这篇文章,我就去找FCKeditor JavaScript API的文档,发现它为客户端JavaScript的调用提供了一些属性和方法,于是乎,就按上述的回答写了一段JavaScript脚本来完成了验证。

详细解决方法:首先添加Javascript脚本:
<script language="javascript"  type="text/javascript">
var oEditer;
function CustomValidate(source, arguments)
{
    var value = oEditer.GetXHTML(true);
    if(value=="")
    {
       arguments.IsValid = false;    
    }
    else
    {
        arguments.IsValid = true;
    }
}
function FCKeditor_OnComplete( editorInstance )

    oEditer = editorInstance;
}
</script>
然后添加CustomValidator,设置ClientValidationFunction="CustomValidate",注意千万别忘了ValidateEmptyText="True",否则不起作用!
这样,再试试,哈哈,一次就可以直接提交了,不会出现提交两次的bug了。