最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2009年06月19日 23:32:24   作者:  
FCKEditor是一個(gè)很不錯(cuò)的在線編輯器,可稱得上完美,但是它有一個(gè)問題,就是在使用RequiredFieldValidator進(jìn)行驗(yàn)證的時(shí)候,即使內(nèi)容不為空,也需要點(diǎn)擊兩次才能完成
經(jīng)過查找網(wǎng)上的資料,發(fā)現(xiàn)好像是它本身的一個(gè)問題,原文如下:

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時(shí),我需要提交兩次
答:當(dāng)RequiredFieldValidator的EnableClientScript屬性被設(shè)置成true時(shí),F(xiàn)CKEditor不能很好的支持RequiredFieldValidator,為了解除這個(gè)限制,你必須把這個(gè)屬性設(shè)置成為false 如果你希望使用客戶端驗(yàn)證,你必須使用Custom Validator制作一個(gè)非空驗(yàn)證來替換RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。 

       看了這篇文章,我就去找FCKeditor JavaScript API的文檔,發(fā)現(xiàn)它為客戶端JavaScript的調(diào)用提供了一些屬性和方法,于是乎,就按上述的回答寫了一段JavaScript腳本來完成了驗(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",注意千萬別忘了ValidateEmptyText="True",否則不起作用!

這樣,再試試,OK,一次就可以直接提交了,不會(huì)出現(xiàn)提交兩次的bug了

相關(guān)文章

最新評(píng)論

蒲江县| 泗洪县| 都江堰市| 五华县| 南昌市| 山东省| 肇东市| 敖汉旗| 环江| 太仆寺旗| 乐清市| 崇明县| 运城市| 华阴市| 离岛区| 梁平县| 邵东县| 正蓝旗| 金平| 昭觉县| 即墨市| 高碑店市| 噶尔县| 淳安县| 旬邑县| 珲春市| 奎屯市| 永定县| 精河县| 万年县| 康保县| 竹溪县| 吴忠市| 茶陵县| 五峰| 夏津县| 和政县| 修武县| 米林县| 无极县| 辽宁省|