Input
Input - Optimised and fully customisable React component
Input Component: Advanced Input Field with Validation and Masking Features in React
The Input component builds upon the native HTML input element and enhances it with an expanded range of field types, each associated with a specific validation pattern. You can specify the field type by utilizing the 'type' property. The Input component has access to the Form handler functions and utilities and should be used as a child in the Form component.
Input properties
Props of the native component are also available.
#
|
#
|
#
|
#
|
#
|
#
|
#
|
Example
import { Form, Input } from 'formfusion';
import './App.css';
const MyForm = () => {
const onSubmit = (data: object) => {
console.log('Form submitted successfully', data);
};
return (
<Form onSubmit={onSubmit} className="form">
<Input
id="username"
name="username"
type="username"
label="Username"
required
classes={{
field: 'input-field',
label: 'input-field__label',
error: 'input-field__error-message',
}}
validation={{
patternMismatch: 'Please match the requested format.',
valueMissing: 'This field is required.',
}}
/>
<button type="submit">Submit</button>
</Form>
);
};
export default MyForm;