我们应该有浏览器端验证吗

发布于 2024-09-04 02:27:46 字数 130 浏览 6 评论 0原文

对于将在内部使用且经过培训的用户使用它的后台应用程序,进行浏览器端验证是否有意义。经过培训后,用户很少会犯错误。这些错误会在服务器端被捕获。另请记住,带宽可用性并不是那么重要,我认为我们应该避免浏览器端验证。这将节省在两个地方维护相同功能的精力。

For a back office application which is going to be used in house and users trained to use it, does it make sense to have browser side validation. After training users will seldom make mistakes. These mistakes would get caught at the server side. Also bearing in mind that the bandwidth availability is a lesser concern I feel we should avoid browser side validations. This will save the effort of maintaining the same functionality at two places.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

薄凉少年不暖心 2024-09-11 02:27:46

您始终需要服务器端验证。

就客户端验证而言,它不仅节省了流量,而且还提高了可用性(立即响应,无需往返服务器)。但它是可选的。

通过在一处定义一些常量并将它们注入 JavaScript 中,您可以最大限度地减少保持两个功能同步的工作量。例如,这对于文本框的输入限制等事情非常有用。

You always need the server-side validation.

As far as the client-side validation goes, not only does it save traffic but it also improves usability (immediate response, no round-trip to server). It is optional though.

You can minimize efforts for keeping two functionalities in sync by defining some constants in one place and injecting them into your JavaScript. That would work nice for such things as the input limit on textboxes, for example.

违心° 2024-09-11 02:27:46

首先在不进行客户端验证的情况下部署您的应用程序。然后观察您的用户来决定添加客户端验证的努力是否值得。

即使对于快速网络上的专家用户来说,客户端验证也可以使应用程序更快一点,使用起来更愉快。

在Java中,您可以使用诸如 Spring 模块验证< /a>.您可以使用注释在 Java 代码中指定验证规则,该库会生成用于客户端验证的 JavaScript 和用于服务器端验证的 Java。整洁的。原始项目已分叉,现在再次开发中。

First deploy your application without client-side validation. Then observe your users to decide whether the effort of adding client-side validation would be worth the benefit.

Even with expert users on a fast network, client-side validation can make the application just that little bit faster and more pleasant to use.

In Java you can use libraries such as Spring Modules Validation. You specify your validation rules in your Java code using annotations, and the library generates JavaScript for client-side validation and Java for server-side. Neat. The original project has been forked and is now under development again.

辞取 2024-09-11 02:27:46

鉴于您描述的情况,我倾向于同意:客户端验证的好处似乎在您的案例中并不重要。只需确保服务器端验证会产生有用的错误消息,并且表单内容不会丢失。

Given the circumstances you describe, I'd tend to agree: the benefits of client-side validation don't seem to weigh heavily in your case. Just make sure that the server-side validation results in useful error messages and the form contents are not lost.

我还不会笑 2024-09-11 02:27:46

客户端验证不仅仅涉及带宽,还涉及用户体验。即使是专家用户在使用应用程序时仍然会犯错误,因此我认为它对于任何现代网络应用程序都是强制性的。

Client-side validation isn't just about bandwidth, it's also about user experience. Even expert users still slip-up when using an application, so I'd consider it mandatory for any modern web app.

爱*していゐ 2024-09-11 02:27:46

我认为,由于您有服务器端验证并且您的目标受众有限,这可能是一个不错的解决方案。

如果服务器端验证为您提供了一些向用户显示的不错的错误消息,那么这对我来说似乎可以接受。

I would argue that since you have serverside validation and your target audience is limited this could be an ok solution.

If the serversidevalidation gives you some decent error-messages that is displayed to a user, this seems acceptable to me.

不可一世的女人 2024-09-11 02:27:46

如果您想在家中使用应用程序来检查一些与工作相关的问题,带宽可能仍然是一个问题。另外,如果您可以立即检查它,那么向服务器发送可能无效的数据有什么意义呢?

If you're going to want to use your app from home to check on some work-related issues, bandwidth might still be a problem. Also, what's the point in sending potentially invalid data to the server, if you could check on it right away?

纵情客 2024-09-11 02:27:46

认为我们需要回顾一下为什么我们需要服务器端验证,除了确保数据在写入时有效之外,我们还需要进行适当的编码以确保用户不会插入任何可能导致诸如此类的恶意输入sql 注入、跨站请求伪造或跨站脚本。你永远不知道你的用户什么时候会尝试做一些有趣的事情。

客户端验证的要点主要是用户体验,用户体验重要吗?如果应用程序将被频繁使用,那么构建验证可能是值得的。输入错误的数据并等待页面返回可以节省用户的一些精力。有时,作为开发人员,我们并没有真正投入太多精力来使程序可用,我们倾向于从功能角度来看待它。

当然,如果时间有限,服务器端验证是必须的。

Think we need to look back at why we need server side validation, besides ensuring that the data is valid while we are writing it, we also need to do proper encoding to ensure that the user is not inserting any malicious inputs that might cause things like sql injection, Cross Site Request Forgery or Cross Site Scripting. U never know when your users might try to do something funny.

The main point of client side validation is mainly user experience, is the user experience important? If the app is going to be use quite frequently, it might be worthwhile to build in the validation. Save the user some effort is typing in wrong data and waiting for the page to come back. Sometimes as developers we don't really put too much effort into making the program usable, we tend to look at it from a functional perspective.

Of course if time is a constraint, server side validation is a must have.

故事还在继续 2024-09-11 02:27:46

浏览器端验证通常称为客户端验证
对于任何应用程序来说,拥有客户端 ID 验证总是好的。

Following are the example of the validations you can check on client side
1]  Mandatory Fields
2]  Field Formatting (only numbers are allowed, special character are not allowed)

&

Following are the example of the validations you can't (or shouldn't) check on client side
1] Username uniqueness
2] 

注意:- 使用客户端和客户端创建应用程序始终是良好的做法。服务器端验证。尽管您应用了客户端验证,但您应该编写服务器端验证代码,因为用户可能会禁用浏览器的 Javascript。

Browser Side Validation oftenly called as CLIENT SIDE VALIDATION.
for any application it's always good to have a client id's validations.

Following are the example of the validations you can check on client side
1]  Mandatory Fields
2]  Field Formatting (only numbers are allowed, special character are not allowed)

&

Following are the example of the validations you can't (or shouldn't) check on client side
1] Username uniqueness
2] 

NOTE:- It's always good practise to create an application with Both Client Side & Server Side Validations. You should write a code for server side validation though you apply a client side validations because it may possible that user can disable a Browser's Javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文