const
demoForm
=
document
.
getElementById
(
'demoForm'
)
;
const
fv
=
FormValidation
.
formValidation
(
demoForm
,
{
fields
:
{
email
:
{
validators
:
{
notEmpty
:
{
enabled
:
true
,
message
:
'The email address is required'
,
}
,
emailAddress
:
{
message
:
'You must enter a valid email address'
,
}
,
}
,
}
,
}
,
}
)
;
change
event of the
Submit anonymously
checkbox, and use the
disableValidator()
and
enableValidator()
methods to toggle these validators:
demoForm
.
querySelector
(
'[name="submitAnonymously"]'
)
.
addEventListener
(
'change'
,
function
(
e
)
{
// Enable or disable validators for the `email` field
e
.
target
.
checked
?
fv
.
disableValidator
(
'email'
)
:
fv
.
enableValidator
(
'email'
)
;
// Revalidate the `email` field
fv
.
revalidateField
(
'email'
)
;
}
)
;