2

I have a problem with my jQuery datepicker.
If I sumbit the form without a value in the datepicker, it tells me to enter a date.
When I do pick a date it's like its not getting updated, and still want me to enter a date.

Look at this fiddle :

http://jsfiddle.net/xa5gn1kq/12/

$(document).ready(function () {

    $("#rental-form").bootstrapValidator({
        framework: 'bootstrap',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        live: 'enabled',
        submitButtons: 'button[id="rental-submit"]',
        fields: {
            datePicker: {
                validators: {
                    notEmpty: {
                        message: 'Velg en dato'
                    },
                    date: {
                        format: 'MM-DD-YYYY',
                        message: 'Datoen er ikke i riktig format, velg fra listen - eller skriv i følgende format: mm-dd-yyyy'
                    }
                }
            }
        }
    });

    $('#datePicker').datepicker({
        dateFormat: 'mm-dd-yy',
        minDate: "0",
        endDate: "01-01-2016",
        todayBtn: "linked",
        autoclose: true,
        onSelect: function (date, inst) {
            $('#data').text(this.value);
            $('#rental-form').formValidation('revalidateField', 'datePicker');
        }
    });
});

Try submitting without a date, then choose a date and see that the validation error isn't removed.

1 Answer 1

2

There is no formValidation plugin, it's still called bootstrapValidator in the datePicker code

$('#datePicker').datepicker({
    dateFormat: 'mm-dd-yy',
    minDate: "0",
    endDate: "01-01-2016",
    todayBtn: "linked",
    autoclose: true,
    onSelect: function (date, inst) {
        console.log('ccc')
        $('#data').text(this.value);
        $('#rental-form').bootstrapValidator('revalidateField', 'datePicker');
    }         //              ^^ here, wrong name !
});

FIDDLE

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.