w-50
class (assuming you're using the
Tachyons
framework).
<
div
class
=
"
cf mb2
"
>
<
div
class
=
"
fl w-100
"
>
<
div
class
=
"
fl w-25 pa2
"
>
Alert on
div
>
<
div
class
=
"
fl w-75
"
>
<
div
class
=
"
w-100 js-alert-field-container
"
>
<
div
class
=
"
fl w-50
"
>
div
>
<
div
class
=
"
fl w-50
"
>
div
>
<
div
id
=
"
alertDayIcon
"
>
div
>
div
>
div
>
div
>
div
>
<
div
class
=
"
cf mb2
"
>
<
div
class
=
"
fl w-100
"
>
<
div
class
=
"
fl w-25 pa2
"
>
div
>
<
div
class
=
"
fl w-75
"
>
<
div
id
=
"
alertDayMessage
"
>
div
>
div
>
div
>
div
>
.js-alert-field-container
element. We need to let the
Tachyons plugin
know how it can find these fields:
const
form
=
document
.
getElementById
(
'demoForm'
)
;
const
fv
=
FormValidation
.
formValidation
(
form
,
{
fields
:
{
...
}
,
plugins
:
{
tachyons
:
new
FormValidation
.
plugins
.
Tachyons
(
{
rowSelector
:
function
(
field
,
ele
)
{
return
field
===
'alertDay'
?
'.js-alert-field-container'
:
'.fl'
;
}
,
}
)
,
}
,
}
)
;
#alertDayIcon
, we need to use
onPlaced option
which is called when the icon element is inserted to the document:
const
fv
=
FormValidation
.
formValidation
(
form
,
{
fields
:
{
...
}
,
plugins
:
{
icon
:
new
FormValidation
.
plugins
.
Icon
(
{
valid
:
'fa fa-check'
,
invalid
:
'fa fa-times'
,
validating
:
'fa fa-refresh'
,
onPlaced
:
function
(
e
)
{
if
(
e
.
field
===
'alertDay'
)
{
document
.
getElementById
(
'alertDayIcon'
)
.
appendChild
(
e
.
iconElement
)
;
}
}
,
}
)
,
}
,
}
)
;
const
fv
=
FormValidation
.
formValidation
(
form
,
{
fields
:
{
...
}
,
plugins
:
{
message
:
new
FormValidation
.
plugins
.
Message
(
{
clazz
:
'red lh-copy'
,
container
:
function
(
field
,
ele
)
{
return
field
===
'alertDay'
?
document
.
getElementById
(
'alertDayMessage'
)
:
FormValidation
.
plugins
.
Message
.
getClosestContainer
(
ele
,
form
,
/
^(.*)fl(.*)$
/
)
;
}
,
}
)
,
}
,
}
)
;