FormValidation
.
formValidation
(
document
.
getElementById
(
'demoForm'
)
,
{
fields
:
{
...
}
,
plugins
:
{
// Validate fields when clicking the Submit button
submitButton
:
new
FormValidation
.
plugins
.
SubmitButton
(
)
,
// Submit the form when all fields are valid
defaultSubmit
:
new
FormValidation
.
plugins
.
DefaultSubmit
(
)
,
...
}
,
}
)
;
<
div
id
=
"
container
"
method
=
"
POST
"
>
...
div
>
<
script
>
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(
e
)
{
FormValidation
.
formValidation
(
document
.
getElementById
(
'container'
)
,
{
fields
:
{
...
}
,
plugins
:
{
defaultSubmit
:
new
FormValidation
.
plugins
.
DefaultSubmit
(
)
,
...
}
,
}
)
;
}
)
;
script
>
<
div
id
=
"
payment
"
>
div
>
<
form
id
=
"
payment
"
>
form
>
<
script
>
document
.
addEventListener
(
'DOMContentLoaded'
,
function
(
e
)
{
FormValidation
.
formValidation
(
document
.
getElementById
(
'payment'
)
,
{
fields
:
{
...
}
,
plugins
:
{
...
}
,
}
)
;
}
)
;
script
>
name="submit"
or
id="submit"
attribute for the submit button.
name="submit"
or
id="submit"
attribute, then
form.submit
will return the submit button instance instead of submitting the form. That's why we can't submit the form.
reset
,
length
,
method
.
<
button
type
=
"
submit
"
name
=
"
submit
"
>
Submit
button
>
<
button
type
=
"
submit
"
id
=
"
submit
"
>
Submit
button
>
<
button
type
=
"
submit
"
name
=
"
submitButton
"
>
Submit
button
>