Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    Feb 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Bootstrap Validator - Send message after form validated

    Hello,

    I have been working around with this Bootstrap Plugin and after all the setup I am just stuck with the confirmation submit message.

    I know how to make the message appear (JSFiddle), but not how to do it just when the form is validated.

    After few tries here is somewhat that (until I know) should work but it does not.

    Code:
    $('#form').validator().on('submit', function (e) {
      if (e.validated.bs.validator()) {
        $('button').click(function(){
            $('.alert').hide()
        }) 
      } else {
        $('button').click(function(){
            $('.alert').show()
        }) 
      }
    })
    Do you guys have any clue?

    Thanks!

  2. #2
    Regular Coder 2reikis's Avatar
    Join Date
    Nov 2005
    Location
    New Mexico, USA
    Posts
    182
    Thanks
    21
    Thanked 13 Times in 13 Posts
    $('button').click(...) adds an event handler to all the buttons on the page. If I understand your question correctly, that's not what you want.

    if you just want to show a message when the submission is not valid, remove the wrapper.

    Code:
    $('#form').validator().on('submit', function (e) {
      if (e.validated.bs.validator()) {
         $('.alert').hide()
      } else {
        $('.alert').show()
      }
    })
    This will hide the alert if the validator returns true and show it if the validator returns false.
    2Reikis
    I did not arrive at my understanding of the physical universe through my rational mind.
    Albert Einstein


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •