Forum Moderators: open
Example Code:
function checkCmnts()
{
var x = document.forms[0].Comments.value;
var filter1 = /^.+url=http+.+$/;
var filter2 = /^.+<+.+$/;
var filter3 = /^.+>+.+$/;
if (filter1.test(x)) document.forms[0].Comments.value = '';if (filter1.test(x)) exit;
if (filter2.test(x)) document.forms[0].Comments.value = '';
if (filter1.test(x)) exit;
if (filter3.test(x)) document.forms[0].Comments.value = '';if (filter1.test(x)) exit;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title></title>
</head>
<body>
<form action="#">
<div>
<textarea name="comments" id="comments" rows="9" cols="15"></textarea>
</div>
</form>
<script type="text/javascript">
window.onload = function() {
var c = document.getElementById('comments');
c.onchange = function() {
var s = this.value;
s = s.replace(/\r\n/g,"::");
alert(s);
};
};
</script>
</body>
</html>