The validation functions that you specified do not reveal any information that you think is necessary to keep secret (quite the contrary, actually telling people what is and what is not needed is useful and can break through to the UI). Therefore, they are โsafeโ in that they do not disclose anything confidential.
If you have validation functions that use information or methods that you want to keep secret, you will need to transfer them to the server because they will not be โsafeโ because they will reveal confidential information.
You can make it difficult for people to understand their client-side validation functions by using an aggressive minifier / obfuscator such as the Google Closure Compiler in advanced mode. But you cannot make this impossible: if the browser can read the code, people using the browser can read the code.
And just because we are talking about client-side verification, the usual warning: despite the fact that you are checking the client side, you still have to check the server side. Users can bypass their code on the client side and send invalid information.
source share