Skip to content

Latest commit

 

History

History
31 lines (31 loc) · 763 Bytes

README.md

File metadata and controls

31 lines (31 loc) · 763 Bytes

Copy paste filter label (can retain the specified label)

HTML code

<div class="con" contenteditable="true"></div>

JS code

$(".con").bind("paste", function(){
    var _this = $(this);
    setTimeout(function(){				
        var con = _this.html();				
        var i, match;
        match = con.match(/<[^>]+>/gi);
	if (match) {
	    for (i in match) {
	        if (!match[i].match(/<(input|div|br).*?(?:>|\/>)/gi)) {
	            con = con.replace(match[i], '');
	        }
	    }
	}
	match = con.match(/{[^}]+}/gi);
	if (match) {
	    for (i in match) {
	        if (!match[i].match(/<(input|div|br).*?(?:>|\/>)/gi)) {
	            con = con.replace(match[i], '');
	        }
	    }
	}
        _this.html(con);
    }, 30)
})