Relying on HTML 'required' for simple form validation

后端 未结 4 1244
栀梦
栀梦 2021-01-25 03:00

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

4条回答
  •  时光取名叫无心
    2021-01-25 03:42

    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.

提交回复
热议问题