Check if HTML contains JavaScript in PHP

html, javascript, php, validation

Solution

It might be better to take a different approach and use something like HTML Purifier to filter out anything that you don't want. I think it would be very difficult to safely remove any possibility of javascript without actually parsing the HTML properly.

Problem

I need to check if user submitted HTML contains any JavaScript. I'm using PHP for validation.

Original source