<
html
>
<
head
>
<
link
rel
=
"
stylesheet
"
href
=
"
/vendors/formvalidation/dist/css/formValidation.min.css
"
/>
head
>
<
body
>
<
form
id
=
"
demoForm
"
method
=
"
POST
"
>
...
form
>
<
script
src
=
"
https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js
"
>
script
>
<
script
src
=
"
/vendors/formvalidation/dist/js/FormValidation.min.js
"
>
script
>
<
script
src
=
"
/vendors/formvalidation/dist/js/plugins/AutoFocus.min.js
"
>
script
>
<
script
>
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(
e
)
{
FormValidation
.
formValidation
(
document
.
getElementById
(
'demoForm'
)
,
{
fields
:
{
...
}
,
plugins
:
{
autoFocus
:
new
FormValidation
.
plugins
.
AutoFocus
(
)
,
submitButton
:
new
FormValidation
.
plugins
.
SubmitButton
(
)
,
...
}
,
}
)
;
}
)
;
script
>
body
>
html
>
vendors
directory. You might need to change the path depending on where you place them on the server.
| Option | Type | Description |
|---|---|---|
onPrefocus
|
Function
|
Invoked before the first invalid element get focused |
onPrefocus
function accepts one parameter:
onPrefocus
:
function
(
e
)
{
// e.field: The field element name
// e.firstElement: The first invalid element
}
onPrefocus
option allows to access the file name via the
field
property
onPrefocus
option that is useful when you want to activate the tab containing the first invalid field