开发学院网页设计JavaScript 利用jquery解决MVC下A potentially dangerous Req... 阅读

利用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();

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

上一页  1 2 3 4  下一页

Tags:利用 jquery 解决

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接