I’m building my site locally.
Since I want users to be able to write only specific terms in the search bar, I put a jQuery script in the wp-content\themes\sitename\js folder. The script works fine, but I noticed that the script can be bypassed in a simple way.
For example, suppose that the search bar accepts only strings with 3 characters, so if I write
abcd and press enter I get an error, but if I write
abc and press enter then it works and the
Search Results page will have the url
But it’s enough to modify the url to be
and press enter, to bypass the search bar script.
How to avoid this?
I have 2 ideas, use the function
get_search_query, or remove the keyword from the url so that independently from the keyword the url will be, for example
But I don't know how to use the function or how to remove the keyword from the url (if it is possibile).