onStatusChanged
option provided by the
FieldStatus plugin
.
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(
e
)
{
const
demoForm
=
document
.
getElementById
(
'demoForm'
)
;
// Get the submit button element
const
submitButton
=
demoForm
.
querySelector
(
'[type="submit"]'
)
;
FormValidation
.
formValidation
(
demoForm
,
{
fields
:
{
...
}
,
plugins
:
{
fieldStatus
:
new
FormValidation
.
plugins
.
FieldStatus
(
{
onStatusChanged
:
function
(
areFieldsValid
)
{
areFieldsValid
// Enable the submit button
// so user has a chance to submit the form again
?
submitButton
.
removeAttribute
(
'disabled'
)
// Disable the submit button
:
submitButton
.
setAttribute
(
'disabled'
,
'disabled'
)
;
}
}
)
,
...
}
,
}
)
;
}
)
;