form表单中存在input,为了避免在input中按下回车键(enter),form表单自动提交的情况,一般都会自己写一些监听事件让其失效。
今天用到的是Semantic UI,所以说下如何在$(#form).form()事件中设定。
https://semantic-ui.com/behaviors/form.html#/settings
在官网中可以查看到有一个keyboardShortcuts属性,设置成false,回车键就不可用了。
今天遇到这个问题,研究了好久都没有解决,最后才在官网的犄角旮旯场发现的。哎,怪自己眼睛不好啊,浏览了三遍官网才找到的。
| Setting | Default | Description |
|---|---|---|
| keyboardShortcuts | true | Adds keyboard shortcuts for enter and escape keys to submit form and blur fields respectively |
| on | submit | Event used to trigger validation. Can be either submit, blur or change. |
| revalidate | true | If set to true will revalidate fields with errors on input change |
| delay | true | Delay from last typed letter to validate a field when using on: change or when revalidating a field. |
| inline | false | Adds inline error on field validation error |
| transition | scale | Named transition to use when animating validation errors. Fade and slide down are available without including ui transitions |
| duration | 150 | Animation speed for inline prompt |
在使用SemanticUI时,为防止form表单因input按键回车而自动提交,可以通过设置`keyboardShortcuts`属性为`false`来禁用这一功能。此设置可在官网文档的细节处找到,有时可能被忽略。通过这个方法,你可以确保表单在按下回车时不触发提交。
802

被折叠的 条评论
为什么被折叠?



