formValidator3.3的ajaxValidator一些異常分析_jquery

來源:互聯網
上載者:User
ajaxvalidator是大家問的最多的問題,修正一個bug(感謝網友“じ龍峸√”),並把大家最關心的問題,再做一次闡述。
bug現象:無論校正有沒有校正通過,當控制項再次得到焦點而再次失去焦點的時候tip裡的提示就會停滯在得到焦點的提示
曆次升級的相關記錄:
a、為AjaxValidator添加一個addidvalue屬性(是否自動添加id和值到url參數後面)
為了修複AjaxValidator在配置資訊的時候,取不到運行時候值的bug,外掛程式將自動在url後面自動添加,形式為"id=value"的網頁參數。
在伺服器端,你可以通過Request.querystring["id"]來取值。 具體示範請看demo1裡的使用者名稱輸入和Default.aspx
異常說明:
開發過程中仍會出現亂碼問題
例如:
複製代碼 代碼如下:

$("#thename").formValidator({onfocus:"使用者名稱至少6個字元,最多40個字元",oncorrect:"輸入格式正確"}).inputValidator({min:6,max:40,onerror:"你輸入的使用者名稱非法,請確認"})//.regexValidator({regexp:"username",datatype:"enum",onerror:"使用者名稱格式不正確"})
.ajaxValidator({
type : "get",
url : "login.do",
data:"action=isExist",
datatype : "xml",
success : function(data){
root = data.documentElement;
var rowSet = root.selectNodes("//delete");
if( rowSet.item(0).selectSingleNode("value").text == "0" )
{
return true;
}
else
{
return false;
}
},
buttons: $("#saveId"),
error: function(){alert("伺服器沒有返回資料,可能伺服器忙,請重試");},
onerror : "該使用者名稱不可用,請更換使用者名稱",
onwait : "正在對使用者名稱進行合法性校正,請稍候..."//function(){alert($("#pcode").val());}
});

說明:
data:"action=isExist&thename="+$('#thename').val(),這種方式是失效的,因為$('#thename').val()是固定不變的,而且是初始值,通常為空白.
修改源碼:
formValidator.js
//ajax校正
ajaxValid : function(returnObj)的方法中
將
var parm = "clientid="+id+"&"+id+"="+encodeURIComponent(srcjo.val());
改為:
var parm = "clientid="+id+"&"+id+"="+encodeURIComponent(encodeURIComponent(srcjo.val()));
因為只有通過前台兩次編碼,後台一次解碼就可以解決亂碼問題
thename=java.net.URLDecoder.decode(thename,"UTF-8");
注意前台必須編碼兩次,否則會仍是亂碼.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.