Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Cannot activate from Javascript #643

Open
rashnk opened this issue Dec 6, 2018 · 0 comments
Open

Cannot activate from Javascript #643

rashnk opened this issue Dec 6, 2018 · 0 comments

Comments

@rashnk
Copy link

rashnk commented Dec 6, 2018

Validator works when I use data-toggle="validator"
<form id="ppForm" data-toggle="validator" action="https://xxx-xx.xx.com/" method="POST" >

but when I try to activate it from javascript , it does not work

    <!-- CDN -->
    <script
      type="text/javascript"
      src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
    ></script>
    <script
      type="text/javascript"
      src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"
    ></script>
    <script
      type="text/javascript"
      src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.min.js"
    ></script>
    <!-- CDN -->
var options = {
        delay: 5000,
        custom: {
          equals: function($el) {
            var matchValue = $el.data('equals'); // foo
            debugger;
            if ($el.val() !== matchValue) {
              return "Hey, that's not valid! It's gotta be " + matchValue;
            }
          }
        }
      };

      $('#ppForm')
        .validator(options)
        .on('submit', function(e) {
          alert('e');
          if (e.isDefaultPrevented()) {
            // handle the invalid form...
            alert('e');
            return;
          } else {
            // everything looks good!
            sbmtForm();
          }
        });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant