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 |