简体   繁体   English

引导日期时间选择器禁用其他字段

[英]bootstrap datetimepicker disabling other fields

I was wondering what the Bootstrap DateTimePicker used for storing the date? 我想知道Bootstrap DateTimePicker用于存储日期吗? I want to know how I can use that object/text/whatever it may be to disable other textbox fields that I have on my web page. 我想知道如何使用该对象/文本/无论如何禁用网页上的其他文本框字段。

I have one page setup for querying against multiple GridViews, so I don't want the user to enter information into multiple fields otherwise more than one GridView will be returned. 我有一个用于查询多个GridView的页面设置,所以我不希望用户在多个字段中输入信息,否则将返回多个GridView。 I have gotten the other textbox fields to become disabled, including the DateTimePicker textbox fields, using the below javascript (jquery): 我已经使用以下javascript(jquery)禁用了其他文本框字段,包括DateTimePicker文本框字段:

$("#tasknameText").keyup(function (e) {
            if ($(this).val() != '') {
                $("#textDate").attr('disabled', 'disabled');
                $("#beginDate").attr('disabled', 'disabled'); //DateTimePicker Field
                $("#endDate").attr('disabled', 'disabled'); //DateTimePicker Field2
                $("#beginDate2").attr('disabled', 'disabled'); //DateTimePicker Field3
                $("#endDate2").attr('disabled', 'disabled'); //DateTimePicker Field4
            } else {
                $("#tasknameText").removeAttr('disabled');
                $("#textDate").removeAttr('disabled');
                $("#beginDate").removeAttr('disabled');
                $("#endDate").removeAttr('disabled');
                $("#beginDate2").removeAttr('disabled');
                $("#endDate2").removeAttr('disabled');
            }
        });

The above code represents four DateTimePicker fields, or two pairs of Start Date and End Date fields. 上面的代码表示四个DateTimePicker字段,或两对开始日期和结束日期字段。 It works to disable all the other textboxs on the page when I use keyup on a regular textbox. 当我在常规文本框上使用keyup时,它可以禁用页面上的所有其他文本框。 However, keyup only works when the user manually enters a date into the DateTimePicker fields - I need it to work when the user clicks the glyphicon icon and the date is automatically populated as well. 但是,只有当用户在DateTimePicker字段中手动输入日期时,按键输入才起作用-当用户单击字形图标并自动填充日期时,我需要它起作用。

Found a way to make it work - instead of using keyup, i just called all the events in the same line and that seemed disabled the other text fields. 找到了一种使其工作的方法-而不是使用keyup,我只是在同一行中调用了所有事件,而这似乎禁用了其他文本字段。 Would still like to know which one specifically it is changing on... 仍然想知道它正在更改的是哪一个...

$("#beginDate").bind("blur focus focusin focusout load resize scroll unload click" + " dblclick mousedown mouseup mousemove mouseover mouseout mouseenter " + "mouseleave change select submit keydown keypress keyup error", function (e) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM