So is it safe to validate form on client-side only?

不问归期 提交于 2019-11-29 04:14:19

No, it is not safe. You should always validate your data on the server side, after the form has been submitted. Client-side validation and AJAX validation before submitting the form are only enhancing the user experience, by providing quicker feedback on invalid data. Both client-side validation and AJAX pre-submit validation do not and can not protect you from a maliciously crafted form submission. Attackers and abusers usually don't even use a browser in order to submit data to your server.

My rules are fairly simple...

  1. If you care about your data, then you must validate on the server.
  2. If you care about your user experience, then you must validate on the client.
Frankey

Since javascript is readable for any visitor, and easily editable with the newest browsers, anyone with a bit programming skills can bypass your javascript validation in no time. So you should validate on the server side also, always.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!