IE中文本内的问号

时间:2017-07-06 09:18:24

标签: javascript asp.net vb.net internet-explorer devexpress

我有一个允许用户输入多个日期的页面。我正在使用devexpress对象。所有工作都在Chrome中找到,但是当我在IE上试用时,问号在文本中添加如下:?7?/?6?/?2017?,?7?/?7?/?2017?< /强>

任何人都可以帮我吗?以下是我的代码。谢谢!

这是我的DevExpress对象

<dx:ASPxDropDownEdit ID="multidate" runat="server" Theme="Material" CssClass="object-style" Width="100%" ClientInstanceName="dd_multidate">
<DropDownWindowTemplate>
<dx:ASPxCalendar ID="ASPxCalendar1" runat="server" CssClass="objform-style" EnableMultiSelect="True" Theme="Material" FastNavStyle-Paddings-Padding="0px" ShowWeekNumbers="false">
 <DayStyle Font-Size="11px" Paddings-Padding="5px" CssClass="multidates"/>
 <ClientSideEvents SelectionChanged="OnSelectionChanged" Init="function(s,e) {
                    s.OnDayMouseDown = function(p1, p2, p3, p4) { ASPxClientCalendar.prototype.OnDayMouseDown.call(s, p1, p2, true, p4);     
                    }
            }"  />
</dx:ASPxCalendar>  
</DropDownWindowTemplate>
</dx:ASPxDropDownEdit>

这就是我获取所选日期的方式

<script type="text/javascript">
    function OnSelectionChanged(s, e) {
        dd_multidate.SetText(s.GetSelectedDates().toLocaleString().replace(/12:00:00 AM,/g, " ").replace(/, 12:00:00 AM/, " ").replace(/ ‎12‎:‎00‎:‎00‎ ‎AM/g, ""));
        //dd_multidate.SetText(s.GetSelectedDates().toLocaleString().replace(/12:00:00 AM/g, "").replace(/, ,/g, ", ").replace(/, /g, ""));
        }
</script>

以下是我的保存代码

<script type="text/javascript">
    $(document).on('click', '#MainContent_btn_submit', function () {
        var param = {};
        param.hdrid = $("#MainContent_TelNum").text();
        param.multidate = $("input[name='dd_multidate']").val();
        console.log(JSON.stringify(param));
        var request2 = $.ajax({
            //async: true,
            //cache: false,
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=UTF-8",
            url: "Instruction.aspx/save_multidate",
            data: JSON.stringify(param)
        });
    });
</script>

这是我的VB代码

<Web.Services.WebMethod()> _
    Public Shared Function save_multidate(hdrid As String, multidate As String) As String
        ', less1 As String, net1 As String, aadd1 As String, bill1 As String, inc As String
        Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("ofs").ConnectionString)
        Dim cmd As New SqlCommand
        cmd.Connection = cn
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "save_Instruction"
        cmd.Parameters.AddWithValue("@inst_hdrid", hdrid)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
        Return hdrid
    End Function

2 个答案:

答案 0 :(得分:3)

通过添加来解决问题。

.replace(/ [^ - 〜] / g,'')

在我的剧本上。

答案 1 :(得分:1)

验证字符串中的问题字符,然后将其删除:Online tool that may display non-printable characters

在IE中,根据地区的不同,可能有必要剥去从左到右的标记(U + 200E)。例如:

return date.toLocaleString().replace(/\u200E/g, '');

改编自:Date format has invisible characters in IE11