我在我的日期选择器中选择了一个日期,但它不需要并提醒"请选择日期格式的日期dd-mm-yyyy"当我提交。
function get_invoice()
{
var client_id = $('#client_name').val();
$.ajax({
type: "POST",
dataType: "json",
data:{'client_id':client_id},
url: "<?= site_url('master/get_invoice') ?>",
success: function (data) {
var table = document.getElementById("item-tables");
$("#item-tables").find("tr:not(:first)").remove();
// $("#tbodyid").empty();
var j=1;
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd;
}
if(mm<10){
mm='0'+mm;
}
var today = dd+'-'+mm+'-'+yyyy;
var date = $('.datepicker').datepicker( {autoclose: true,dateFormat: 'dd-mm-yy' } );
for (var i = 0; i < data.invoice.length; i++){
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var balance = parseFloat(data.invoice[i].amount)-parseFloat(data.invoice[i].paid);
row.insertCell(0).innerHTML= '<input type="text" class="form-control date datepicker has Datepicker input-sm" size="16" name="date'+j+'" id="date'+j+'" value="">';
row.insertCell(1).innerHTML= '<input type="text" class="form-control" name="invoice_id'+j+'" id="invoice_id'+j+'" value = "' + data.invoice[i].invoice_code +'" readonly>';
j++;
}
$('.datepicker').datepicker( {autoclose: true,dateFormat: 'dd-mm-yy' } );
}
});
}
答案 0 :(得分:0)
试试这个
var date = $('.datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();
答案 1 :(得分:0)
不确定是否是原因 - 但是你的datepicker dateFormat声明的格式与“today”变量的格式不同。尝试修改你的dateFormat为全年(yyyy),如下所示
reprex_as_pdf <- system2(
command = "texi2pdf",
args = c("reprex.tex", "-o", "/dev/stdout"),
stdout = TRUE, stderr = TRUE
)