国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

asp.net 控件驗(yàn)證 FCKeditor

2020-01-18 01:14:02
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
經(jīng)過(guò)查找網(wǎng)上的資料,發(fā)現(xiàn)好像是它本身的一個(gè)問(wèn)題,原文如下:

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.


譯文如下(翻譯的不好,大家能看懂就好):
問(wèn):為什么在使用ASP.NET的RequiredFieldValidator時(shí),我需要提交兩次
答:當(dāng)RequiredFieldValidator的EnableClientScript屬性被設(shè)置成true時(shí),F(xiàn)CKEditor不能很好的支持RequiredFieldValidator,為了解除這個(gè)限制,你必須把這個(gè)屬性設(shè)置成為false 如果你希望使用客戶端驗(yàn)證,你必須使用Custom Validator制作一個(gè)非空驗(yàn)證來(lái)替換RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。 

       看了這篇文章,我就去找FCKeditor JavaScript API的文檔,發(fā)現(xiàn)它為客戶端JavaScript的調(diào)用提供了一些屬性和方法,于是乎,就按上述的回答寫(xiě)了一段JavaScript腳本來(lái)完成了驗(yàn)證。

詳細(xì)解決方法:首先添加Javascript腳本:
復(fù)制代碼 代碼如下:

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,設(shè)置ClientValidationFunction="CustomValidate",注意千萬(wàn)別忘了ValidateEmptyText="True",否則不起作用!

這樣,再試試,OK,一次就可以直接提交了,不會(huì)出現(xiàn)提交兩次的bug了
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 闸北区| 德惠市| 镇雄县| 浦县| 萨嘎县| 波密县| 临沭县| 林芝县| 长顺县| 黔东| 房山区| 中西区| 玛纳斯县| 茶陵县| 武隆县| 中方县| 五台县| 太白县| 资源县| 习水县| 五寨县| 将乐县| 沾化县| 内丘县| 乌海市| 三台县| 大英县| 花垣县| 遂昌县| 达拉特旗| 双鸭山市| 兰西县| 杂多县| 新津县| 正蓝旗| 杭州市| 荆门市| 茌平县| 杭州市| 探索| 信阳市|