3.0.5 • Published 7 years ago

hire-forms-input v3.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Hire Forms Input

React Component representing an input element.

Value as a property

The <Input />s value isn't an internal state, but is passed as a property! In other words: your app has state and passes it to the <Input />. See the examples.

Examples

Default

render() {
	return (
		<Input
			onChange={this.handleChange.bind(this)}
			placeholder="Enter value..."
			value={this.state.value} />
	);
}

With validation

The onInvalid prop isn't required. If a validator function returns isValid: false and a message string, the message string will be a TextNode of <div className="hire-forms-invalid-message" />.

let validateNumbersOnly = function(value) {
	// Handle validation.
	let re = /^\d+$/;
	let isValid = re.test(value);

	// Return a validator object.
	return {
		isValid: isValid,
		message: isValid ? "" : "Only numbers are allowed."
	};
};

...

handleInvalid(message, value) {

}

...

render() {
	return (
		<Input
			onChange={this.handleChange.bind(this)}
			onInvalid={this.handleInvalid.bind(this)}
			placeholder="Enter value..."
			validate={validateNumbersOnly}
			value={this.state.value} />
	);
}
3.0.5

7 years ago

3.0.4

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago