0.3.2 • Published 9 months ago

@inftechsol/reactstrap-form-validation v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@inftechsol/reactstrap-form-validation

About component

It is a simle form component with validator. This component's base is reactstrap Form, and Inputs and all props comes from there.

Compatibility

This component use React v18.1.0, react-dom v18.1.0, Bootstrap v5.1.3 and reactstrap v9.0.2.

Installation

npm i @inftechsol/reactstrap-form-validation

Basic usage

import { useState } from 'react';
import { RVForm, RVFormGroup, RVInput, RVFormFeedback } from '@inftechsol/reactstrap-form-validation';
import { Button, Label } from 'reactstrap';

const App = () => {
    const defaultObj = {
        address: '',
        name: '',
        age: ''
    };

    const style = {
        padding: '20px'
    };

    const [obj, setObj] = useState(defaultObj);

    const handleInputChange = (e) => {
        const { target } = e;
        const { name, type, checked, value } = target;
        const newValue = type === 'checkbox' ? checked : value;

        setObj({
            ...obj,
            [name]: newValue
        });
    };

    const onSubmit = (e) => {
        e.preventDefault();
        console.log('Event: ', e);
    };

    return (
        <div style={style}>
            <RVForm onSubmit={onSubmit}>
                <RVFormGroup>
                    <Label>Address:</Label>
                    <RVInput required name="address" value={obj.address} onChange={handleInputChange} />
                    <RVFormFeedback>This is soooo good...</RVFormFeedback>
                </RVFormGroup>
                <RVFormGroup>
                    <Label>Name: </Label>
                    <RVInput required name="name" value={obj.name} onChange={handleInputChange} />
                    <RVFormFeedback>This field is required!</RVFormFeedback>
                </RVFormGroup>
                <RVFormGroup>
                    <Label>Age: </Label>
                    <RVInput required type="number" name="age" value={obj.age} onChange={handleInputChange} />
                    <RVFormFeedback>This field is required!</RVFormFeedback>
                </RVFormGroup>
                <Button type="submit">Send</Button>
            </RVForm>
        </div>
    );
};

export default App;

Properties

All comes from reactstrap Forms and Inputs except RVForm onSubmitFrom. See Reactstrap form and input props

0.3.2

9 months ago

0.3.1

9 months ago

0.3.0

11 months ago

0.2.7

11 months ago

0.2.9

11 months ago

0.2.8

11 months ago

0.2.6

1 year ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago