| Field status | Icon |
|---|---|
| Valid |
check
|
| Invalid |
clear
|
| Being validated |
graphic_eq
|
:after
CSS selector, we can indicated content of icons as following:
.material-icons
.valid-icon
:after
{
content
:
'check'
;
font-size
:
24
px
;
}
.material-icons
.invalid-icon
:after
{
content
:
'clear'
;
font-size
:
24
px
;
}
.material-icons
.validating-icon
:after
{
content
:
'graphic_eq'
;
font-size
:
24
px
;
}
icon
:
new
FormValidation
.
plugins
.
Icon
(
{
valid
:
'material-icons valid-icon'
,
invalid
:
'material-icons invalid-icon'
,
validating
:
'material-icons validating-icon'
,
}
)
,
plugins.icon.set
as mentioned in the
Using SVG icons
section above.
FormValidation
.
formValidation
(
document
.
getElementById
(
'demoForm'
)
,
{
plugins
:
{
icon
:
new
FormValidation
.
plugins
.
Icon
(
{
valid
:
'material-icons icon-valid'
,
invalid
:
'material-icons icon-invalid'
,
validating
:
'material-icons icon-validating'
,
}
)
,
}
,
}
)
.
on
(
'plugins.icon.set'
,
function
(
e
)
{
if
(
e
.
iconElement
)
{
switch
(
e
.
status
)
{
case
'Validating'
:
e
.
iconElement
.
innerHTML
=
'graphic_eq'
;
break
;
case
'Invalid'
:
e
.
iconElement
.
innerHTML
=
'clear'
;
break
;
case
'Valid'
:
e
.
iconElement
.
innerHTML
=
'check'
;
break
;
default
:
e
.
iconElement
.
innerHTML
=
''
;
break
;
}
}
}
)
;