React JSX:

<input
    type="password"
    name="password"
    value={this.state.password}
    minLength={2}
    maxLength={4}
    required="required"
    onChange={e => this.handleOnChange(e)}
    placeholder="Password"/>


处理程序:

handleOnChange = (e) => {
    console.dir(e.target)
    console.dir(e.target.minLength) // ==> expected value is 2, but undefined
    console.dir(e.target.maxLength) // ==> 4


在Chrome中,我可以找到“ minLength”。但是在Safari中,缺少“ minLength”的键值巴黎。

“ maxLength”确实存在。

我没有解决这个问题,Safari是否不实现“ minLength”?

版:


Safari 9.1.1(11601.6.17)

最佳答案

不,Safari没有实现它:http://caniuse.com/#feat=input-minlength

您可能要尝试使用pattern属性或该问题的其他答案之一:Is there a minlength validation attribute in HTML5?

关于javascript - Safari在ReactDom中缺少“minLength”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37948334/

10-12 04:59