Javascript String sanitize()

Description

Javascript String sanitize()


String.prototype.sanitize = function(){
    return this.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

Javascript String sanitize()

String.prototype.sanitize = function() {
    return $('<div/>').text(this).html();
};

Javascript String sanitize()

String.prototype.sanitize = function() {
  return this/* w w  w. j  a  v  a2  s  .c  o m*/
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;')
    .replace(/'/g, '&#39;')
}



PreviousNext

Related