Reputation: 71
I am doing an input check on an <input type='text'/>
field using JavaScript / JQuery.
The problem: As far as I tried, you can edit JS code using the developer mode and change the JS code for the input check to always return true.
The question: Is there a way to prevent the JS code from being changed such that the input check cannot be fooled, and is JS even a safe (not necessarely the safest) option here? Or would it be better to use PHP in this case?
Upvotes: 0
Views: 983
Reputation: 6180
You cannot, in any way, hide JavaScript from the user. As you stated, you should use server-side technologies such as PHP, where the user will no longer be able to see or alter the processing involved.
A commonly used practice is to validate the entered data in the browser, and then revalidate it on the server, to ensure no altering of validation rules has been made by the user.
Upvotes: 5
Reputation: 176
You can make it harder, by doing <script src="***"></script>
, but I aree there isn't a way to make it non editable.
Upvotes: 1