Skip to content

calling Validator twice breaks multiple dateinput #150

Closed
@michan85

Description

@michan85

Description

calling validator more than once causes only last dateinput on page to show popup.

i came accross this while dynamically adding fields to a form, and then calling
validator again to ensure those fields get validated.

Reproduce

Copy HTML

<form method="post" action="ui.php?action=validate" class="form"><h2>Add a field</h2><ul><li><label for="date">date</label><input type="date" required="required" name="date" class="date"></li><li><label for="date">date</label><input type="date" required="required" name="date" class="date"></li></ul><script type="text/javascript">
    (function(){

        $(":date").dateinput();
        $(":range").rangeinput();
        $("form")
            .validator()
            .submit(function(e) {

            var form = $(this);

            // client-side validation OK.
            if (!e.isDefaultPrevented()) {

                // submit with AJAX
                $.post("ui.php?action=validate", form.serialize(), function(resp) {

                    alert( resp );
                });

                // prevent default form submission logic
                e.preventDefault();     
            }
        });
    })();
</script></form>

from fire bug console call

  • $("form").validator()

then click on a date input control

  • they should not pop up.

Work Around

comment out this code in
validator.js -> Validator -> destroy:
//inputs.unbind(conf.inputEvent || '').unbind("change.V");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions