Is JavaScript validation bad?

后端 未结 14 1908
栀梦
栀梦 2021-02-01 11:56

It has been long time since we have been validating our forms using JavaScript. I am sure this must be the case with most other developers.

Question:

What if the

14条回答
  •  你的背包
    2021-02-01 12:23

    If you learn only one thing from this topic, let it be this:

    Never — under any circumstances — trust data from the browser and always validate request data on the server-side.

    Should we ever use it now?

    Yes, definitely. You do not need to validate an empty field on the server side. It is not something like validating an email's availability (uniqueness of email). If you are going to reject that empty field anyway, there is no point of sending it to server and making server do extra work for it.

提交回复
热议问题