new InputGroup(inputsArray, submitElems, onValidationSuccess, onValidationFailure, pendingUiStartopt, pendingUiStopopt, groupStatesChangedopt, groupPendingChangedopt, onBeforeValidationopt, onAfterValidationopt, resetElemsopt)
creates a new InputGroup
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
inputsArray |
Array.<vivalid.Input> | the group's state is evalutated by: invalid: if at least 1 inputs in inputsArray is invalid pending: if all inputs in inputsArray are valid/pending and at least 1 is pending valid: if all inputs in inputsArray are valid |
|
submitElems |
Array.<HTMLElement> | an array of elements that should trigger the group's validation. The elements click event will either immediately trigger onValidationSuccess / onValidationFailure, or go through pendingUiStart and pendingUiStop if the group is in 'pending' mode. | |
onValidationSuccess |
function | signature of onValidationSuccess. A function called when a submitElem is clicked and group state is valid or as a callback after it reaches a valid state from a pending state. Use this function to proceed with the application flow. | |
onValidationFailure |
function | signature of onValidationFailure. A function called when a submitElem is clicked and group state is invalid or as a callback after it reaches an invalid state from a pending state. Use this function to show message about the form state for the user. | |
pendingUiStart |
function |
<optional> |
signature of pendingUiStart. highly recommneded when using asyc client-server validations. A function called when a submitElem is clicked and group state is pending. Use this function to show a loader or disable inputs while the group waits for the pending validations to complete. |
pendingUiStop |
function |
<optional> |
signature of pendingUiStop. highly recommneded when using asyc client-server validations. A function called when leaving a group pending state after a submitElem is clicked. Use this function to undo the UX effects taken inside pendingUiStart. |
groupStatesChanged |
function |
<optional> |
|
groupPendingChanged |
function |
<optional> |
|
onBeforeValidation |
function |
<optional> |
Signature of onBeforeValidation. A function to be called before triggering any of the input's validators |
onAfterValidation |
function |
<optional> |
Signature of onAfterValidation. A function to be called after triggering all of the input's validators |
resetElems |
Array.<HTMLElement> |
<optional> |
an array of elements that should trigger the group's validation _reset. |
- Source: