gpt4 book ai didi

jquery - 未捕获的范围错误: Invalid language tag on Chrome

转载 作者:行者123 更新时间:2023-11-30 23:59:45 25 4
gpt4 key购买 nike

我有一个 MVC jquery 移动应用程序,在其中一个页面上我有一个日期时间选择器,当我与 jqyery.validate 一起使用时,即使我在选择器上没有任何验证,也会在 chrome 上出现此错误。我实际上想验证另一个控件。我将粘贴代码:主视图:

@model MvcAppMobileJQuery.ViewModels.OrderVM
@{
ViewBag.Title = "";
Layout = "~/Views/Shared/Layouts/_BaseLayout.cshtml";
}
@section Content
{
<div id="contentDiv">
<div style="margin-top: -31px;">
@using (Html.BeginForm("SaveOrder", "Orders"))
{
<table class="tableFormLayout" cellpadding="0" cellspacing="0">
<tr>
<td>
@Html.LabelFor(m => m.OrderDate, new { @class = "ui-input-text" })
@Html.TextBox("OrderDate", @Model.OrderDate.ToString("dd MMMM yyyy"), new { data_mini = "true", id = "orderDate" })
</td>
</tr>
<tr>
<td>
<input type="button" id="openOrderItemAddPopup" value="Add" />
</td>
</tr>
</table>
@Html.Partial("~/Views/Orders/OrderItemAddPopup.cshtml", Model)
}
</div>
</div>
}
@section Style
{
@Styles.Render("~/Content/mobileScrollControlCss")
}
@section Scripts
{
@Scripts.Render("~/bundles/jquerymobileScrollControl")
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function () {
// create a datepicker with default settings
$("#orderDate").scroller({
preset: 'date',
theme: 'jqm',
display: 'modal',
mode: 'mixed',
//animate: 'pop',
dateOrder: 'dd mm yy',
dateFormat: 'd MMMM yyyy'
});
});

</script>
}

这是从主视图打开的弹出窗口,其中包含验证:

@model MvcAppMobileJQuery.ViewModels.OrderVM

<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

<div data-role="none" id="OrderItemAddPopup" data-overlay-theme="b" style="width: 500px;"
class="ui-corner-all">
<div data-role="content">
@Html.ValidationSummary()
@using (Html.BeginForm())
{
<table class="tableFormLayout" cellpadding="0" cellspacing="0">
<tr>
<td>
@Html.LabelFor(m => m.Quantity, new {@class = "label"})
</td>
<td>
@Html.TextBoxFor(m => m.Quantity, new {data_mini = "true", type = "number", id = "txtQuantity"})
</td>
</tr>
<tr>
<td colspan="2">
<a noloader="true" href="#" id="closeOrderItemAddPopup" data-role="button" data-inline="true"
data-icon="back">Cancel</a>
<input type="button" id="load" data-inline="true" value="Save" data-url="@Url.Action("LoadItemsPartial", "Orders")" data-icon="forward"/>
</td>
</tr>
</table>
}
</div>
</div>
<script type="text/javascript">
$('#load').click(function () {
$('form').valid();
});

$(function () {
$('#OrderItemAddPopup').modalPopLite({ openButton: '#openOrderItemAddPopup', closeButton: '#closeOrderItemAddPopup', isModal: true });
//LoadOrderItems();
});
</script>

因此,当我单击日期选择器时,我会从 chrome 上的标题中收到消息。另外,如果我不单击它并打开弹出窗口,则尝试保存弹出窗口数据。如果我从选择器中取出验证,它就可以正常工作。

最佳答案

我已经成功解决了这个问题,感谢fretje的回答this发布。

我还必须更改这一行:

@Html.TextBox("OrderDate", @Model.OrderDate.ToString("dd MMMM yyyy"), new { data_mini = "true", id = "orderDate" })

@Html.TextBox("OrderDate", @Model.OrderDate.ToString("dd-MM-yyyy"), new { data_mini = "true", id = "orderDate" })

脚本部分现在看起来像这样:

@section Scripts
{
@Scripts.Render("~/bundles/jquerymobileScrollControl")
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function () {
// create a datepicker with default settings
$("#orderDate").scroller({
preset: 'date',
theme: 'jqm',
display: 'modal',
mode: 'mixed',
//animate: 'pop',
dateOrder: 'dd mm yy',
dateFormat: 'dd-mm-yy'
});
});

$(function () {
// Replace the builtin US date validation with UK date validation
$.validator.addMethod(
"date",
function (value, element) {
var bits = value.match(/([0-9]+)/gi), str;
if (!bits)
return this.optional(element) || false;
str = bits[1] + '/' + bits[0] + '/' + bits[2];
return this.optional(element) || !/Invalid|NaN/.test(new Date(str));
},
""
);
});

</script>
}

关于jquery - 未捕获的范围错误: Invalid language tag on Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18482230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com