How do I use Bootstrap 3 form validation when submit button is outside the form?

前端 未结 3 718
谎友^
谎友^ 2021-02-06 07:46

I\'m confused with the Bootstrap 3 implementation of form validation. I\'m new to Bootstrap, and I cannot seem to get the form validation working with a form that does not incl

3条回答
  •  忘掉有多难
    2021-02-06 08:05

    I have done some research, and I now know that the form validation I was seeing was not a function of Bootstrap but a new CSS3 / HTML5 feature. I don't believe it is possible (without JS) to perform this form validation unless the submit button is enclosed within the form. Here is an example of what was not working:

    http://jsfiddle.net/hTPY7/1112/

    Here's an example of how it was fixed:

    http://jsfiddle.net/hTPY7/1113/

    The

    element needs to surround more than just the form, but also surround the Bootstrap modal divs.

    Here is another post which summarizes my problem well:

    HTML5 form validation for AJAX button submit

提交回复
热议问题