﻿
//Methos for htmlencoding all < and > withing text or textarea elements
function ClearHtmlTags() {

    jQuery.each($('input[type=text], textarea'), function() {
        //alert("start each");
        //alert(this.value);

        if (this.value.indexOf("<") >= 0) {
            do {
                this.value = this.value.replace("<", "&lt;")
            }
            while (this.value.indexOf("<") >= 0);
        }

        if (this.value.indexOf(">") >= 0) {
            do {
                this.value = this.value.replace(">", "&gt;")
            }
            while (this.value.indexOf(">") >= 0);
        }
    });

}

function RevertHtmlTags() {

    jQuery.each($('input[type=text], textarea'), function() {
        //alert("start each");
        //alert(this.value);

        if (this.value.indexOf("&lt;") >= 0) {
            do {
                this.value = this.value.replace("&lt;", "<")
            }
            while (this.value.indexOf("&lt;") >= 0);
        }

        if (this.value.indexOf("&gt;") >= 0) {
            do {
                this.value = this.value.replace("&gt;", ">")
            }
            while (this.value.indexOf("&gt;") >= 0);
        }

    });
}