Description:
This JavaScript checks to see if any HTML tags are used in a text area form box. If they are found, they are deleted.
JavaScript Functions: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function Del(Word) { a = Word.indexOf("<"); b = Word.indexOf(">"); len = Word.length; c = Word.substring(0, a); if(b == -1) b = a; d = Word.substring((b + 1), len); Word = c + d; tagCheck = Word.indexOf("<"); if(tagCheck != -1) Word = Del(Word); return Word; } function Check() { ToCheck = document.form.text.value; Checked = Del(ToCheck); document.form.text.value = Checked; alert("This form is not set to submit anywhere so you will stay here. But please notice that the text box's contents have been \"filtered\"."); return false; } // End --> </SCRIPT>
HTML Script: <form action="some.cgi" name=form onSubmit="return Check()"> <textarea cols="50" rows="6" name="text"></textarea> <br> <input type="submit" value="Submit Entry"> </form>