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
It uses [React context](https://github.com/reactjs/reactjs.org/blob/d59c4f9116138e419812e44b0fdb56644c498d3e/content/docs/context.md) to share the [`FieldsStore`](packages/react-form-with-constraints/src/FieldsStore.ts) object across [`FieldFeedbacks`](packages/react-form-with-constraints/src/FieldFeedbacks.tsx) and [`FieldFeedback`](packages/react-form-with-constraints/src/FieldFeedback.tsx).
109
+
It uses [React context](https://reactjs.org/docs/legacy-context.html) to share the [`FieldsStore`](packages/react-form-with-constraints/src/FieldsStore.ts) object across [`FieldFeedbacks`](packages/react-form-with-constraints/src/FieldFeedbacks.tsx) and [`FieldFeedback`](packages/react-form-with-constraints/src/FieldFeedback.tsx).
110
110
111
111
## API
112
112
@@ -162,7 +162,7 @@ class MyForm extends React.Component {
162
162
// Validates the non-dirty fields and returns Promise<Field[]>
if (formIsValid) console.log('The form is valid');
@@ -236,7 +236,7 @@ class MyForm extends React.Component {
236
236
-`info?: boolean` => treats the feedback as an info
237
237
-`children` => what to display when the constraint matches; if missing, displays the [HTML5 error message](https://www.w3.org/TR/html51/sec-forms.html#the-constraint-validation-api) if any
238
238
239
-
-[`Async<T>`](packages/react-form-with-constraints/src/Async.tsx) => Async version of `FieldFeedback`, similar API as [react-promise](https://github.com/capaj/react-promise)
239
+
-[`Async<T>`](packages/react-form-with-constraints/src/Async.tsx) => Async version of `FieldFeedback` (similar API as [react-promise](https://github.com/capaj/react-promise))
240
240
-`promise: (value: string) => Promise<T>` => a promise you want to wait for
241
241
-`pending?: React.ReactNode` => runs when promise is pending
242
242
-`then?: (value: T) => React.ReactNode` => runs when promise is resolved
@@ -248,15 +248,21 @@ class MyForm extends React.Component {
248
248
Should be called when a `field` changes, will re-render the proper `FieldFeedback`s (and update the internal `FieldsStore`).
249
249
Without arguments, all fields (`$('[name]')`) are validated.
Validates only all non-dirty fields (won't re-validate fields that have been already validated with `validateFields()`),
253
+
If you want to force re-validate all fields, use `validateFields()`.
254
+
251
255
-`validateForm(): Promise<Field[]>` =>
252
-
Should be called before to submit the `form`. Validates only all non-dirty fields (won't re-validate fields that have been already validated with `validateFields(...)`),
253
-
If you want to force re-validate all fields, use `validateFields()` without arguments.
256
+
Other name for `validateFieldsWithoutFeedback()`, typically called before to submit the `form`.
257
+
Might be removed in the future?
254
258
255
-
-`isValid(): boolean` => should be called after `validateForm()`or `validateFields()`, tells if the fields are valid
259
+
-`isValid(): boolean` => should be called after `validateFields()`, `validateFieldsWithoutFeedback()`or `validateForm()`, tells if the fields are valid
256
260
257
261
-`hasFeedbacks(): boolean` => tells if the fields have any kind of feedback
258
262
259
-
-`reset(): Promise` => resets internal `FieldsStore` and re-render all `FieldFeedback`s
@@ -281,7 +287,10 @@ class MyForm extends React.Component {
281
287
282
288
## Browsersupport
283
289
284
-
YoucanuseHTML5attributeslike`type="email"`, `required`, `pattern`..., inthiscasea [recentbrowser](http://caniuse.com/#feat=forms) is needed,...
290
+
react-form-with-constraintsneeds [`ValidityState`](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState) which is supported by all modern browsers and IE >= 10.
291
+
Italsoneedsapolyfillsuchas [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/usage/polyfill/) to support IE <= 11, see [React JavaScript Environment Requirements](https://reactjs.org/docs/javascript-environment-requirements.html).
react-form-with-constraintsneedsapolyfillsuchas [core-js](https://github.com/zloirock/core-js) or [babel-polyfill](https://babeljs.io/docs/usage/polyfill/) to support IE 11 and lower. See also [React JavaScript Environment Requirements](https://reactjs.org/docs/javascript-environment-requirements.html).
311
-
312
319
## Notes
313
320
314
321
- A [`type="hidden"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden#Validation), [`readonly`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-readonly) or [`disabled`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-disabled) input won't trigger any HTML5 form constraint validation like [`required`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-required), see https://codepen.io/tkrotoff/pen/gdjVNv
0 commit comments