使用 HTML5 的新输入类型显示表单错误
目前,HTML5 的新输入类型
<input type="number"...>
<input type="email"...>
<input type="url"...>
仅关注表单提交时用户输入不匹配的任何违规文本框。
问题:对焦没问题。然而,这是一种非常微妙的方式来告诉用户为什么表单没有提交。
以下哪一个是让用户知道出了什么问题的更好解决方案:
- Add css on a focus textbox by 添加背景颜色。依然是 稍微微妙,用户可能会 不能立即理解为什么 特定的文本框被聚焦。
- JavaScript 验证(jQuery 验证插件)用于显示错误消息。既然如此,我不妨使用普通的输入类型,并在这里完成所有操作。
欢迎提出建议!
Currently, HTML5's new input types,
<input type="number"...>
<input type="email"...>
<input type="url"...>
simply focus on any offending text-boxes with mismatching user input upon form submission.
Problem: Focusing is fine. However it's a very subtle way of telling the user why the form is not submitting.
Which of these is the better solution to let the user know what's wrong:
- Add css on a focused textbox by
adding a background color. It's still
slightly subtle and the user might
not immediately understand why a
particular textbox is focused. - Javascript validation (jQuery
validation plugin) for displaying error messages. In which case, I might as well use ordinary input types, and do everything here.
Suggestions are welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据良好的旧可用性启发法:
http://www.useit.com/papers/heuristic/heuristic_list.html
最好的选择是清楚地通知用户错误(不仅是在哪里发生的,而且是为什么......)。除此之外,UI 应该足够清晰,以防止用户进行未经允许的输入。
恕我直言,您可以使用 JQuery 进行错误处理,仍然保留 html5 类型,它们在“语义上”比普通输入类型更好。
According to good old usability heuristics:
http://www.useit.com/papers/heuristic/heuristic_list.html
The best choice is to clearly notify the user about the error (not only where has happened, but also why...). Above that the UI should be clear enough to prevent the user from unallowed input.
IMHO you can use JQuery for error handling, still leaving html5 types, which are "semantically" better than ordinary input types.
让它们变红。
Make them go red.