1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Improve validation for non-HTML5 inputs

This commit is contained in:
Tim Daubenschütz 2015-11-10 15:51:24 +01:00
parent 62eb78ae76
commit aec850a905

View File

@ -305,14 +305,14 @@ let Form = React.createClass({
let refToValidate = {};
const property = this.refs[refName];
const input = property.refs.input;
const value = input.getDOMNode().value;
const value = input.getDOMNode().value || input.state.value;
const { max,
min,
pattern,
required,
type } = input.props;
refToValidate.required = required ? value !== '' : true;
refToValidate.required = required ? value : true;
refToValidate.pattern = pattern && typeof value === 'string' ? value.match(pattern) : true;
refToValidate.max = type === 'number' ? parseInt(value) <= max : true;
refToValidate.min = type === 'number' ? parseInt(value) >= min : true;