You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HTML日期控件未显示传入值问题求助

Fixing Date Input Display Issue in Edge (Works in IE)

Hey there! Let's break down why your date input is acting up in Edge but working fine in IE. The root of the problem comes down to how modern browsers handle date input formats compared to the more lenient older IE.

What's Causing the Problem?

Modern Chromium-based Edge strictly follows the HTML standard for native <input type="date"> controls: the value attribute must be in ISO 8601 format (yyyy-MM-dd). Your current output is 12/4/2020 (mm/dd/yyyy), which Edge doesn't recognize—so it defaults to showing the placeholder instead of your intended date. IE, being an older browser, was more flexible with date formats, which is why it worked there.

Step-by-Step Fix

You need to adjust your ASP code to output the date in the ISO 8601 format. Here's a reliable way to do that:

<%
' Assume your incoming date value is stored in a variable called incomingDate
Dim isoFormattedDate
' Build the ISO date string manually to ensure consistent formatting
isoFormattedDate = Year(incomingDate) & "-" & _
                   Right("0" & Month(incomingDate), 2) & "-" & _
                   Right("0" & Day(incomingDate), 2)
%>

<!-- Use the formatted date in your input control -->
<input type="date" value="<%= isoFormattedDate %>">

This code converts a date like 12/4/2020 to 2020-12-04—a format Edge (and all other modern browsers) will correctly parse and display in the date picker.

Extra Tips

  • Eliminate Ambiguity: Using ISO format also removes confusion between date conventions (e.g., is 12/4/2020 December 4th or April 12th?), which helps both frontend display and backend SQL Server insertion.
  • Custom Date Pickers?: If you're using a third-party date control (not the native HTML one), check its docs for a format setting—make sure it matches the format you're passing from ASP.

内容的提问来源于stack exchange,提问作者Dustin Duckworth

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 17:17:55