【问题标题】:Phonegap iOS 10 input type "date" not able to show valuePhonegap iOS 10 输入类型“日期”无法显示值
【发布时间】:2017-02-16 08:15:07
【问题描述】:

我正在 phonegap/cordova 中创建应用程序,并且我创建了输入类型为 - 文本、日期的表单。 所以

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

在 iOS 10 之前支持上述 html,但是当我更新 iphone 6s 时,会显示原生日期选择器,但我给“type=date”的值没有显示,但值存在(当我通过 alert($(".profile-page-dob").val()) 即 1996 年检查时-05-01 )。

如果有专家有什么问题请告诉我。

谢谢

【问题讨论】:

    标签: javascript jquery ios cordova phonegap-plugins


    【解决方案1】:

    我刚刚找到了一些棘手的方法,因为 ios10 正在显示所选日期的值但占位符正在工作,然后我只是使用 change,focusin & 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();                  
                })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-04
      • 2017-02-16
      • 1970-01-01
      • 2018-12-31
      • 2021-04-27
      • 2015-09-14
      • 2021-05-06
      • 2013-09-28
      相关资源
      最近更新 更多