doushan5245 2013-04-21 16:25
浏览 73
已采纳

依赖HTML'required'进行简单的表单验证

My question is simple, I'm writing a simple login/registration form for my website using HTML, PHP and jQuery.

Is it neccesary to write the form validation in PHP also when I could use HTML-s required tag on each input and use PHP to check for username availability and password match?

I believe it is good practice to also have a validation in the back-end but it would appear that the 'required' function in HTML takes care of all that? Can this be misused easily, what are the general drawbacks of solely relying on HTML for simple form validation?

  • 写回答

4条回答 默认 最新

  • duandeng2265 2013-04-21 16:28
    关注

    Is it neccesary to write the form validation in PHP also

    You can never depend on any form of client side validation. It can always be bypassed.

    People might be using browsers that don't support HTML 5 validation attributes, or might use a DOM inspector to remove them.

    JavaScript solutions can be trivialy bypassed by turning off JavaScript.

    Forms can be copy/pasted, edited and then submitted from a page owned by the user.

    HTTP requests can be constructed by hand without going near a form.

    etc. etc.

    Client side validation can only ever be provided for the convenience of the user. The protection of your systems can only be handled server side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算