javascript - 禁用浏览器滚动到错误输入
问题描述
当我提交表单并且表单有错误时,例如空的必需输入,浏览器会向上滚动到该输入。我不想要那个。我有自定义滚动到错误的输入和浏览器滚动干扰我的。如何禁用此功能?
顺便说一句,我使用 react-hook-form
解决方案
当您使用 useForm 钩子创建表单时,您只需将其设置shouldFocusError
为 false
例如
const { register } = useForm({
// ... other settings
shouldFocusError: false,
})
推荐阅读
- javascript - HTML5 / CSS3 / JavaScript的Android
- javascript - Javascript 时间提前或落后
- excel - 使用自动筛选条件对昨天工作日的列中的所有记录筛选数据
- php - 个性化内容
- pandas - df.replace 在尝试替换熊猫数据框中的日期时没有任何效果
- python - PySpark 中的 Groupby 和 UDF/UDAF,同时保持 DataFrame 结构
- html - React - 将 html 标签放在 json 内容中
- javascript - Javascript如何获取输入
- json - NSCocoa 使用 Swift 从 PHP 脚本接收 JSON 数据时出错
- python - 访问没有循环的嵌套字典