Semantic UI form表单验证快捷键失效

在使用SemanticUI时,为防止form表单因input按键回车而自动提交,可以通过设置`keyboardShortcuts`属性为`false`来禁用这一功能。此设置可在官网文档的细节处找到,有时可能被忽略。通过这个方法,你可以确保表单在按下回车时不触发提交。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

form表单中存在input,为了避免在input中按下回车键(enter),form表单自动提交的情况,一般都会自己写一些监听事件让其失效。

今天用到的是Semantic UI,所以说下如何在$(#form).form()事件中设定。

https://semantic-ui.com/behaviors/form.html#/settings

在官网中可以查看到有一个keyboardShortcuts属性,设置成false,回车键就不可用了。

 

今天遇到这个问题,研究了好久都没有解决,最后才在官网的犄角旮旯场发现的。哎,怪自己眼睛不好啊,浏览了三遍官网才找到的。

SettingDefaultDescription
keyboardShortcutstrueAdds keyboard shortcuts for enter and escape keys to submit form and blur fields respectively
onsubmitEvent used to trigger validation. Can be either submitblur or change.
revalidatetrueIf set to true will revalidate fields with errors on input change
delaytrueDelay from last typed letter to validate a field when using on: change or when revalidating a field.
inlinefalseAdds inline error on field validation error
transitionscaleNamed transition to use when animating validation errors. Fade and slide down are available without including ui transitions
duration150Animation speed for inline prompt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值