Customization
To customize your form, you can use the useRapidForm hook to access the form state and validation functions using the refValidation function to validate the form fields.
Let’s see how to customize the form with Rapid Form:
-
Import the
useRapidFormhook into your file:import { useRapidForm } from 'rapid-form'; -
Add
useRapidFormhook to your component:export function MyComponent() {const { refValidation } = useRapidForm()// Your component code goes here} -
Add
refValidationto your form and customize your form fields validation:<formref={(ref) => {const config = {validations: {'input-name': {eventType: 'blur'validation: ({ value }) => value.length > 10,message: 'The input must be more than 10 characters'}}}refValidation(ref, config)}}><input type="text" required name="input-name" /><input type="email" required name="email" /><button type="submit">Submit</button></form>