How to display the date field using bootstrap and jQuery and display in the IOS devices with disabled functionality for date field.

using bootstrap and jQuery we can display in the IOS devices with disabled functionality for date field by using normal date picker. in the html type date will not work for the IOs device using this method we can display for the IOS devices also.

 $('head').append('<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>');
                        $('head').append('<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>');
                        $(document).ready(function() {
                            newDate = new Date();
                            newDate.setDate(newDate.getDate() + 3);
                            console.log("date", newDate);
                            datepicker = formatDate(newDate);
                            console.log("date1", datepicker);

                            function formatDate(strvalue) {
                                var d = new Date(strvalue),
                                    month = '' + (d.getMonth() + 1),
                                    day = '' + d.getDate(),
                                    year = d.getFullYear();
                                return [month, day, year].join('/');
                            }
                            try {
                                var shippingDate = $('#example1').val();
                                if (shippingDate != null) {
                                    $('#example1').datepicker({
                                        autoclose: true,
                                        format: "m/d/yyyy",
                                        startDate: newDate
                                    });
                                }
                            } catch (error) {
                                console.error(error);
                            }
                        });

Leave a comment

Your email address will not be published. Required fields are marked *