0

React JSX:

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

handler:

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

In Chrome, I'm able to find the "minLength". But in Safari, missing key-value paris of "minLength".

"maxLength" does exist.

I don't have a grip of this problem, Does Safari not implement "minLength"?

Version:

  • Safari 9.1.1 (11601.6.17)

1 Answers1

1

Nope, Safari doesn't implement it: http://caniuse.com/#feat=input-minlength

You might want to try using the pattern attribute or one of the other answer to this question: Is there a minlength validation attribute in HTML5?

Community
  • 1
  • 1
Radio-
  • 3,151
  • 21
  • 22