In react, is it better to have form validation checks such as if email is proper or not on client or on server? Wouldn’t it be more faster on client, but less secure. For example, let’s say you have a login form with react. In the login form, you could have two fields: an email field and a password field. Let’s also say you wanted to check if the email was a valid email. Would it be more efficient and secure to do this check on the server and make the server reply to the client or the client just handles all kind of checks like that. Or perhaps would it be best to do the checks on both client and server?
>Solution :
As far as validations are concerned, it is always advisable that they are carried out both on the client and on the server as the APIs are public, therefore anyone can make calls. As far as the client is concerned, it is correct to add validations to avoid overloading the server with useless calls and to reduce traffic. The thing I recommend is to have an API to retrieve the validation regexes and then use them both on the client and on the server.