Validating ajax search

Is there a way to prevent user from entering <img src=x onerror=alert(test)> script tag to the form? My current search page is using ajax to load search result upon entering on the input field. I have look into sanitize function but still not able to resolve.

I have also installed the plugin: Prevent XSS Vulnerability