【问题标题】:Edit form with default Jquery date values, jquery sets current date for field after page is loaded使用默认 Jquery 日期值编辑表单,jquery 在页面加载后为字段设置当前日期
【发布时间】:2011-01-12 07:17:19
【问题描述】:
$(document).ready(function(){
 $('#data_nasterii').datepicker($.datepicker.regional['ro']); // romanian language
 $('#data_nasterii').datepicker('option', 'changeMonth', true); // dropdown with month
 $('#data_nasterii').datepicker('option', 'changeYear', true); // dropdown with year
 $('#data_nasterii').datepicker('option', 'yearRange', '1900:2020'); // selectable years
 $('#data_nasterii').datepicker('option', 'dateFormat', 'yy-mm-dd'); // date format(ex: 1981-07-25)

});

...
// creating date field with php

echo "<td><div align=\"left\"><input name=\"data_nasterii\" type=\"text\" id=\"data_nasterii\" value=\"".$row['data_nasterii']."\" size=\"10\" maxlength=\"10\" /></div></td></tr>";

如果我点击“清除表单”字段得到正确的值

提前谢谢你!

【问题讨论】:

    标签: jquery forms datepicker default-value


    【解决方案1】:

    设置选项的正确方法不是像你一样一次又一次地重复它们。

    $(this).datepicker({
            showButtonPanel: true,
            closeText: 'X',
            dateFormat: 'mm/dd/yy',
            buttonText: 'Select Date',
            showOn: 'button',
            duration: 'fast'
        });
    

    尝试以这种格式执行并查看。 也尽量不要在日期对象中设置值,并尝试在页面加载后使用 java 脚本进行设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 2015-10-02
      • 2013-05-21
      • 1970-01-01
      • 2013-01-12
      • 1970-01-01
      相关资源
      最近更新 更多