教你50招提升ASP.NET性能(六):为了生动的用户体验,总是在客户端验证

时间:2021-07-28 20:33:21

(12)For a snappy user experience, always validate on the client

招数12:

为了生动的用户体验,总是在客户端验证

To avoid unnecessary round trips to the server, validate form entries on the client using JavaScript before posting them. This provides quick feedback and makes your application feel more responsive. Always make sure you explain your validation errors as well. If you use complex password rules or regex patterns, include a message to explain what the rules are to prevent user frustration.
避免不必要的服务器往返,提交表单前使用JavaScript在客户端上验证表单项。这提供了快速反馈让你的应用体验更灵活。总是确保你很好得解释你的验证错误。如果你使用复杂的密码规则或者正则表达式,为了防止用户受挫包括解释这些规则的信息。