Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input 无法限制输入 #560

Closed
neewbee opened this issue Apr 29, 2019 · 4 comments
Closed

input 无法限制输入 #560

neewbee opened this issue Apr 29, 2019 · 4 comments
Labels
invalid This doesn't seem right

Comments

@neewbee
Copy link

neewbee commented Apr 29, 2019

问题描述
无法限制 input 的输入

复现步骤

  1. 修改 input 组件的 handleInput 方法
  handleInput (stateName, value) {
    const regexp = /[^a-zA-Z]+/g;
    const newValue = value.replace(regexp, '');
    this.setState({
      [stateName]: newValue
    })
    return newValue
  }
  1. input 应该无法输入 特殊字符
// 这里可以贴代码

期望行为
无法输入特殊字符
报错信息
可以输入
系统信息
👽 Taro v1.2.20

Taro CLI 1.2.20 environment info:
System:
OS: macOS 10.14.4
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node
npm: 6.9.0 - ~/.nvm/versions/node/v8.15.1/bin/npm

补充信息

@Garfield550
Copy link
Collaborator

你好,你的写法有误,看这个问题
NervJS/taro#2642 (comment)

@neewbee
Copy link
Author

neewbee commented Apr 29, 2019

没有吧,我 return 了这个 value 呀

@jimczj
Copy link
Contributor

jimczj commented Jun 13, 2019

image
这个是可以的,如果不行试试升级版本

@jimczj jimczj added the invalid This doesn't seem right label Jun 13, 2019
@jimczj jimczj closed this as completed Jun 14, 2019
@xzedx
Copy link

xzedx commented Feb 5, 2020

不行呀,还是有这个问题,onBlur事件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants