To prevent with XSS in JavaScript

/*To prevent with XSS*/
function cleanText(str){
var result = str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
return result;
}

ajax.set("NAME",cleanText($('#NAME').val()));

/*//To prevent with XSS*/
/*To remove whitespace in search box*/
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm,'');
}


$("#txtsearch").keyup(function(){
var input = {};
input["NAME"] = myTrim($("#txtsearch").val());
giant_pagin.loadData(input);
});

/*//To remove whitespace in search box*/
Previous Post Next Post