Is it enough to avoid javascript injection validating input data in such way:
xssValidate = function(value) {
var container = $("<u></u>").text(value);
if($(container).html() != value) return mc.ERROR_INVALID_FORMAT;
}
I've managed to validate all the text fields and textareas values with the code above before submit them to server.