【问题标题】:dateFormat in datebox won't effect日期框中的 dateFormat 不会生效
【发布时间】:2012-12-10 06:04:17
【问题描述】:

我正在尝试使用 dateFormat 创建一个日期框,但看起来 dateFormat 不起作用。 它给出了日/月/年,但我只想要月/年

这是我的jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
    <link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" />
    <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
    <script src="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.calbox.min.j‌​s"></script>
    <script src="http://dev.jtsage.com/cdn/datebox/i18n/jquery.mobile.datebox.i18n.en_US.utf8.js"></script>
</head>
<body>
    <div data-role="page">
        <input type="date" name="date" data-role="datebox" data-options='{"mode":"calbox","dateFormat":"%m/%Y"}' />
    </div>
</body>
</html>

我看到了这个thread,但我仍然不明白为什么它不起作用。

【问题讨论】:

    标签: html jsp date datepicker


    【解决方案1】:

    您提供的代码似乎存在问题:

    http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.calbox.min.j‌​s
    

    在“j‌​s”之间包含一些隐藏字符。通常,它是 6a73 的十六进制,但在您的情况下,由于某种原因,它是 6ae2808ce2808b73,所以将该链接更改为

    http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.calbox.min.js
    

    Proof

    但是,要回答您的问题,请尝试使用:

        <link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
        <link type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" rel="stylesheet" /> 
        <link type="text/css" href="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.min.css" rel="stylesheet" /> 
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script> 
        <script type="text/javascript" src="http://code.jquery.com/mobile/latest/jquery.mobile.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/jquery.mousewheel.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.core.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.calbox.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.datebox.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.flipbox.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.durationbox.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.slidebox.min.js"></script>
        <script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/i18n/jquery.mobile.datebox.i18n.en_US.utf8.js"></script>
        <div data-role="page">
            <input type="date" name="date" data-role="datebox" data-options='{"mode":"datebox","overrideDateFormat":"%m/%Y","overrideDateFieldOrder": ["m", "y"],"calUsePickers": true, "calNoHeader": true,"calShowDays": false,"calMonthMode": true}' />
        </div>​
    

    仅强制选择月/年

    Live Demo | Source

    【讨论】:

    • 它可以工作,但是 (grrr) 在 chrom 中它仍然无法工作。当我用 chrome 作为 html 文件打开这个文件时,它正在工作,但是当我从我的服务器(http://...)将它作为 jsp 文件打开时,它也向我展示了这一天(在 fire fox 中它的工作双方)跨度>
    • 在 chrome 上仍然无法正常工作,但我找到了方法:我在控制台中看到了 --> [阻止] localhost/test.jsp 的页面运行了来自 code.jquery.com/mobile/latest/jquery.mobile.css 的不安全内容。还有更多这样的......有办法避免这种情况吗?
    • 尝试下载文件并将其移动到您的服务器,然后更新链接以指向该文件。
    • 链接资源 don't use https 等在您的网站上不起作用
    • 非常感谢您的帮助!!!所以问题是因为我()使用 https 页面,()错过了一些脚本,并且()worng char 在“dev.jtsage.com/cdn/datebox/latest/…”中再次感谢“extramaster”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多