[removed] client-side vs. server-side validation

后端 未结 13 768
余生分开走
余生分开走 2020-11-21 11:58

Which is better to do client side or server side validation?

In our situation we are using

  • jQuery and MVC.
  • JSON data to pass between our Vi
13条回答
  •  攒了一身酷
    2020-11-21 12:20

    JavaScript can be modified at runtime.

    I suggest a pattern of creating a validation structure on the server, and sharing this with the client.

    You'll need separate validation logic on both ends, ex:

    "required" attributes on inputs client-side

    field.length > 0 server-side.

    But using the same validation specification will eliminate some redundancy (and mistakes) of mirroring validation on both ends.

提交回复
热议问题