0

在他的官方页面上https://redux-form.com/6.6.1/examples/fieldlevelvalidation/

“Age”字段是 Redux-forms 如何错误地假设字母 e 可以是 keyPress 上的有效字符的一个示例,而不是只允许数字。

我尝试了以下验证,以排除字母 e,但没有成功:

export const onlyNumber = (value) => {
  return /^[^e]$|[0123456789]$/i.test(value);
};

什么可能是跳过 Redux-Forms 验证方式并实际能够创建仅数字(不包括“e”)字段的成功方法?

4

1 回答 1

0

这是一个功能,它允许'e'的事实......在 Github 中向@iam​​andrewluca 大喊,在以下位置回答我的问题:https ://github.com/erikras/redux-form/issues/4538

类似的问题,以及禁止在堆栈溢出中显示“e”的响应/解决方法: https ://stackoverflow.com/a/31706796/4671932

文档: https://html.spec.whatwg.org/multipage/input.html#number-state-(type%3Dnumber)

于 2019-09-17T16:55:52.513 回答