With ASP.Net, I need to submit twice when using the RequiredFieldValidator in a FCKeditor instance FCKeditor will not work properly with the Requ " /> 欧美蜜桃一区二区三区,久久青草久久,亚洲国产一区二区久久

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net 控件驗證 FCKeditor

經過查找網上的資料,發現好像是它本身的一個問題,原文如下:

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",否則不起作用!

這樣,再試試,OK,一次就可以直接提交了,不會出現提交兩次的bug了

AspNet技術asp.net 控件驗證 FCKeditor,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 图木舒克市| 娄底市| 攀枝花市| 中卫市| 郎溪县| 法库县| 博罗县| 会同县| 孟津县| 定远县| 广西| 同心县| 汉阴县| 巴彦县| 祁阳县| 永新县| 罗甸县| 彭泽县| 比如县| 武平县| 小金县| 八宿县| 楚雄市| 大丰市| 海伦市| 汉寿县| 嵊州市| 云林县| 米泉市| 五华县| 乌审旗| 互助| 治县。| 郯城县| 青铜峡市| 南城县| 隆回县| 长顺县| 渭南市| 山东省| 泰安市|