You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To make certain fields mandatory in your form, you can use the `requiredFields` option when using the `useForm` hook. In the example below, the `email` field is set as a required field:
This ensures that the form cannot be submitted unless the `email` field is filled out by the user.
65
+
66
+
67
+
## Custom error messages
68
+
You can customize the error messages displayed when certain fields are not filled out in your form. By using the `errorMessages` option in the `useForm` hook, you can provide custom error messages for different scenarios.
69
+
70
+
Here's an example of how you can set custom error messages for the `name` and `email` fields:
71
+
72
+
```typescript
73
+
const [state, handleSubmit] =useForm("form_id", {
74
+
requiredFields: ["name", "email"],
75
+
errorMessages: {
76
+
empty: "Please fill the form!",
77
+
required: fields=>`Please fill the required fields: ${fields.join(", ")}`,
78
+
}
79
+
});
80
+
```
81
+
82
+
Feel free to customize the error messages according to your specific requirements.
83
+
84
+
57
85
## ****Useful Links and Information****
58
86
59
87
For more information visit the [documentation](https://formbold.com/docs).
0 commit comments