利用jquery解决MVC下A potentially dangerous Request.QueryString value was detected from the client问题
2010-09-14 13:45:28 来源:WEB开发网3.load时进行解码
$(document).ready(function() {
$("#xmlContent").val(decodeURI($("#xmlContent").val()));
$.formValidator.initConfig();
$("#xmlContent").formValidator({ onshow: "please input XML", onfocus: "XML required", oncorrect: "OK" })
.inputValidator({ min: 20, empty: { leftempty: false, rightempty: false, onerror: "XML length at least 20"} });
});
解决方法2:利用ajax进行表单验证,保证提交的一定正确
1.添加验证
$(document).ready(function() {
// $("#xmlContent").val(decodeURI($("#xmlContent").val()));
$.formValidator.initConfig();
$("#xmlContent").formValidator({ onshow: "please input XML", onfocus: "XML required",
oncorrect: "OK" })
.inputValidator({ min: 20, empty:
{ leftempty: false, rightempty: false, onerror: "XML length at least 20"} })
.ajaxValidator({
type: "get",
url: "checkXML",
datatype: "json",
success: function(responseText) {
if (responseText == "1") {
return true;
}
else {
return false;
}
},
buttons: $("#button"),
error: function() { alert("server busy,try later..."); },
onerror: "XML Format error",
onwait: "XML checking,please wait..."
});;
});
用了猫冬大侠写的formValidator.js
更多精彩
赞助商链接