Phonegap iOS 10输入类型"日期"无法显示价值

时间:2016-10-07 10:45:34

标签: javascript jquery ios cordova phonegap-plugins

我在phonegap / cordova中创建应用程序,我创建了输入类型为 - text,date的表单。 所以

<input placeholder="DOB" type="date"  class="form-control profile-page-dob" >

以上html在iOS 10之前支持但是当我更新iphone 6s然后本机日期选择器显示但是我给予的值&#34; type = date&#34;没有显示,但有值(当我通过alert($(".profile-page-dob").val())检查,即1996-05-01)。

如果有专家得到了什么请告诉我。

由于

1 个答案:

答案 0 :(得分:0)

我刚刚找到了一些棘手的方法,因为ios10显示了所选日期的值,但是占位符正在工作,然后我只使用更改,焦点和&amp;添加了占位符属性中的值。 focusout 函数来处理datepicker值。

            $(".profile-page-dob").change(function(){
                // alert(1)
                $(this).attr('type','date')
                $(this).attr('placeholder',$(this).val())
                $(this).attr('value',$(this).val())
                $(this).val($(this).val());
                userDob = $(this).val();                       
                // alert($(".profile-page").html())
            })

            $(".profile-page-dob").focusin(function(){
                $(this).attr('type','date')
                $(this).attr('placeholder',$(this).val())
                $(this).attr('value',$(this).val())
                $(this).val($(this).val())
                userDob = $(this).val();             
            })


            $(".profile-page-dob").focusout(function(){
                $(this).attr('type','date')
                $(this).attr('placeholder',$(this).val())
                $(this).attr('value',$(this).val())
                $(this).val($(this).val())
                userDob = $(this).val();                  
            })