mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Improve validation for non-HTML5 inputs
This commit is contained in:
parent
62eb78ae76
commit
aec850a905
@ -305,14 +305,14 @@ let Form = React.createClass({
|
|||||||
let refToValidate = {};
|
let refToValidate = {};
|
||||||
const property = this.refs[refName];
|
const property = this.refs[refName];
|
||||||
const input = property.refs.input;
|
const input = property.refs.input;
|
||||||
const value = input.getDOMNode().value;
|
const value = input.getDOMNode().value || input.state.value;
|
||||||
const { max,
|
const { max,
|
||||||
min,
|
min,
|
||||||
pattern,
|
pattern,
|
||||||
required,
|
required,
|
||||||
type } = input.props;
|
type } = input.props;
|
||||||
|
|
||||||
refToValidate.required = required ? value !== '' : true;
|
refToValidate.required = required ? value : true;
|
||||||
refToValidate.pattern = pattern && typeof value === 'string' ? value.match(pattern) : true;
|
refToValidate.pattern = pattern && typeof value === 'string' ? value.match(pattern) : true;
|
||||||
refToValidate.max = type === 'number' ? parseInt(value) <= max : true;
|
refToValidate.max = type === 'number' ? parseInt(value) <= max : true;
|
||||||
refToValidate.min = type === 'number' ? parseInt(value) >= min : true;
|
refToValidate.min = type === 'number' ? parseInt(value) >= min : true;
|
||||||
|
Loading…
Reference in New Issue
Block a user