Keith Power
Keith Power

Reputation: 14141

jQuery Script Doesn't Work on iOS 5

The following script works on all browsers and devices, but since the release of iOS 5 on the iphone, it no longer works.

The following code calculates dates into inputs so I can send them in a form. However, now the dates show up as NaN.

Cant see why.

        function makeUpDates(){
            // concantenate values to date_start and date_end hidden inputs
            var dateString = document.getElementById('date').value,
            date = new Date(dateString);

            document.getElementById('date_start').value = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + ("0" + date.getDate()).slice(-2);

            var numDays = document.getElementById('slider').value;
            date.setDate(date.getDate() + parseInt(numDays));   

            var dateEnd = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + ("0" + date.getDate()).slice(-2);
            document.getElementById('date_end').value = dateEnd;
        }

Upvotes: 0

Views: 343

Answers (1)

Keith Power
Keith Power

Reputation: 14141

The issue was I was missing the override code on the inputs. This was never an issue with other browsers, just iso5 on the iphone

<script>
 //reset type=date inputs to text
 $( document ).bind( "mobileinit", function(){
 $.mobile.page.prototype.options.degradeInputs.date = true;
 });    
</script>   

Upvotes: 1

Related Questions