简体   繁体   中英

Do i need to print PHP form validation Errors to user?

I have a login and signup forms i handle validation with JS like showing user messages if email isnt in the right form also minimum characters number etc, the question is as everyone says we must add a server side validation to stay safe from the case user changed or disabled JS in browser, but does that means i dont need and its impossible to show this errors to client side in case he disabled JS cause its disabled? in general do you write some logic code for that kind of simple form validation errors to user, or this validation errors are only important for developer? if user disabled JS i think react app wont work either so that doesnt make sense and thats what i see

在此处输入图像描述

The Server validations are just there to make sure that you are safe that basically means you should not rely on the front-end validations at all. However, you can validate the request with Clientside/JS as well so you won't need an extra call to API to validate the inputs .

In-case of disabled Javascript , you may ask the user to enable or otherwise, you will not be notified of any error .

 <noscript>
    <span style="color:red">JavaScript is not enabled!</span>
</noscript>

Server-side validation is must-have . It must be implemented always as it's only guaranteed it cannot be skipped.

Client-side validation is just for user's comfort, he doesn't need to send a request as basic mistakes can be catch during inputting data. Remember that it can be skipped easily within a common browser, so you cannot rely on its safety.

Always best solution is combining both: client-side for comfort and server-side for security.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM