kilvalidate 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README_NEXTJS.md +22 -0
- package/package.json +1 -1
package/README_NEXTJS.md
CHANGED
|
@@ -46,6 +46,28 @@ export default function Page() {
|
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
## Hook Options
|
|
50
|
+
|
|
51
|
+
- `useKilvalidate()` attaches to all forms on the page.
|
|
52
|
+
- `useKilvalidate({ form: formRef })` attaches only to a specific form.
|
|
53
|
+
- `useKilvalidate({ auto: false })` disables auto-init if you want manual control.
|
|
54
|
+
|
|
55
|
+
## Manual Init (No Hook)
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
'use client';
|
|
59
|
+
import kilvalidate from 'kilvalidate';
|
|
60
|
+
|
|
61
|
+
export default function Page() {
|
|
62
|
+
return (
|
|
63
|
+
<form id="signup" onSubmit={(e) => kilvalidate.validateForm('#signup', e)}>
|
|
64
|
+
<input name="firstname" required />
|
|
65
|
+
<button type="submit">Submit</button>
|
|
66
|
+
</form>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
49
71
|
## React Form Libraries
|
|
50
72
|
|
|
51
73
|
KilValidate can be used alongside form libraries, but it will not update React state. You can run it inside your submit handler to block submit:
|