在验证时阻止日历控件打开
On validation prevent calender control to open
我想阻止在验证触发时打开保存按钮上的日历控件,我找不到如何阻止它
我在表单中有一个日历控件,select日期验证在保存按钮上触发验证后它将直接聚焦在日历控件上并自动打开日历,业务不想打开日历控件
HTML
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="form-group datepicker">
<label>Project Start Date </label>
<asp:TextBox ID="ProjectStartDate" TabIndex="27" ClientIDMode="Static" runat="server" CssClass="form-control"></asp:TextBox>
<asp:HiddenField ID="hdnProjectStartDate" runat="server" Value="" />
</div>
</div>
我想阻止在保存按钮上打开日历
让我知道那里是否有任何解决方案
谢谢
您使用的是什么日历或日期选择器控件? jQuery UI、Telerik AJAX、控制工具包 AJAX、Kendo?
对于一般的 ASP.NET 验证方案,文本框不会自动聚焦。您需要将以下 属性 设置为 True 明确地执行此操作:
SetFocusOnError="true"
<asp:TextBox runat="server" ID="ProjectStartDate"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Required"
ForeColor="Red" ControlToValidate="ProjectStartDate" SetFocusOnError="false">
</asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Submit" />
您可以检查您的代码隐藏是否在某处定义了此 属性。
我已解决此问题以更改 formValidation.JS
在这个文件中有一个函数
// Determined the first invalid field which will be focused on automatically
var ns = this._namespace;
for (var i = 0; i < this.$invalidFields.length; i++) {
var $field = this.$invalidFields.eq(i),
autoFocus = this.isOptionEnabled($field.attr('data-' + ns + '-field'), 'autoFocus');
if (autoFocus) {
// Focus the field
//$field.focus();
return false;
break;
}
}
在验证时它将自动聚焦该元素并在聚焦日历控件之后
因为焦点自动打开
注释此行以防止焦点放在日历控件上
$field.focus();
谢谢!!
我想阻止在验证触发时打开保存按钮上的日历控件,我找不到如何阻止它
我在表单中有一个日历控件,select日期验证在保存按钮上触发验证后它将直接聚焦在日历控件上并自动打开日历,业务不想打开日历控件
HTML
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="form-group datepicker">
<label>Project Start Date </label>
<asp:TextBox ID="ProjectStartDate" TabIndex="27" ClientIDMode="Static" runat="server" CssClass="form-control"></asp:TextBox>
<asp:HiddenField ID="hdnProjectStartDate" runat="server" Value="" />
</div>
</div>
我想阻止在保存按钮上打开日历
让我知道那里是否有任何解决方案
谢谢
您使用的是什么日历或日期选择器控件? jQuery UI、Telerik AJAX、控制工具包 AJAX、Kendo?
对于一般的 ASP.NET 验证方案,文本框不会自动聚焦。您需要将以下 属性 设置为 True 明确地执行此操作:
SetFocusOnError="true"
<asp:TextBox runat="server" ID="ProjectStartDate"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Required"
ForeColor="Red" ControlToValidate="ProjectStartDate" SetFocusOnError="false">
</asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Submit" />
您可以检查您的代码隐藏是否在某处定义了此 属性。
我已解决此问题以更改 formValidation.JS
在这个文件中有一个函数
// Determined the first invalid field which will be focused on automatically
var ns = this._namespace;
for (var i = 0; i < this.$invalidFields.length; i++) {
var $field = this.$invalidFields.eq(i),
autoFocus = this.isOptionEnabled($field.attr('data-' + ns + '-field'), 'autoFocus');
if (autoFocus) {
// Focus the field
//$field.focus();
return false;
break;
}
}
在验证时它将自动聚焦该元素并在聚焦日历控件之后 因为焦点自动打开
注释此行以防止焦点放在日历控件上
$field.focus();
谢谢!!