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

validate on click issue #663

@jasonwu513

Description

@jasonwu513

Dear Sir:

I'm a newbie for bootstrap-validator , try to follow document and make a example but fail, no matter the validate pass or not , it will alert fail once I click the input box , and even the input is correct , try to study #74 , but still not sure if I could use button click event , thanks in advnace.

`

<title>Title Page</title>
<form role="form" data-toggle="validator" id="validator">
    <legend>Form title</legend>

    <div class="form-group">
        <label for="inputName" class="control-label">label</label>
        <input type="text" class="form-control" id="inputName" placeholder="Input field" required>
    </div>
    <div class="form-group">
        <label for="inputName2" class="control-label">label2</label>
        <input type="email" class="form-control" id="inputName2" placeholder="Input field" required>
    </div>


    <button type="submit" id="submitButton" form="validator" class="btn btn-primary">Submit</button>

</form>


<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Bootstrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.min.js"></script>
<script>
    $('#validator').validator().on('click', function (e) {
        e.preventDefault(); // prevent default
        if (e.isDefaultPrevented()) { // validate fail
            alert(' fail');
            return;
        } else { // validate
            alert('success');
        }

        alert('456');
    });
</script>
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions