const
demoForm
=
document
.
getElementById
(
'demoForm'
)
;
FormValidation
.
formValidation
(
demoForm
,
{
fields
:
{
username
:
{
validators
:
{
...
}
}
}
,
plugins
:
{
...
}
,
}
)
.
on
(
'core.validator.validated'
,
function
(
e
)
{
if
(
!
e
.
result
.
valid
)
{
// Query all messages
const
messages
=
[
]
.
slice
.
call
(
demoForm
.
querySelectorAll
(
'[data-field="'
+
e
.
field
+
'"][data-validator]'
)
)
;
messages
.
forEach
(
(
messageEle
)
=>
{
const
validator
=
messageEle
.
getAttribute
(
'data-validator'
)
;
messageEle
.
style
.
display
=
validator
===
e
.
validator
?
'block'
:
'none'
;
}
)
;
}
}
)
;