datepicker删除日期时出错

datepicker删除日期时出错

本文介绍了telerik datepicker删除日期时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有一个telerik datepicker,如下所示:


HiI have a telerik datepicker as below:


<div class="sxlb">
                               <asp:Label ID="lblLastBackgroundCheckedDate" runat="server" AssociatedControlID="dpLastBackgroundCheckedDate"
                                   Text="Last Background Checked Date"></asp:Label></div>
                           <div class="sxlm">
                               <lpsfs:SysXDatePicker  runat="server" ID="dpLastBackgroundCheckedDate" DateInput-ReadOnly="true"
                                   DateInput-DateFormat="MM-dd-yyyy" Width="99%">
                                   <ClientEvents  önPopupClosing="FocusOnPopUpButton" />
                                   <Calendar ID="calLastBackgroundCheckedDat"  runat="server" EnableKeyboardNavigation="true"
                                       CausesValidation="false">
                                   </Calendar>
                               </lpsfs:SysXDatePicker>
                               <div class="vldx">
                                   <asp:CompareValidator ID="cmpLastBackgroundCheckedDate" ControlToValidate="dpLastBackgroundCheckedDate"
                                       class="errmsg" ValidationGroup="grpSupplierInformation" Operator="LessThanEqual"
                                       Display="Dynamic" ValueToCompare='<%# DateTime.Today.ToShortDateString() %>'
                                       Type="Date" runat="server" ErrorMessage='<%#SysXUtils.GetMessage(ResourceConst.SUPPLIER_INFORMATION_LAST_BACKGROUND_CHECKED_DATE) %>'></asp:CompareValidator>
                               </div>
                           </div>



现在,如果我在此按退格键,它将无法正常工作,
我试图做以下事情::



now if i press backspace on this,it is not working,
I tried to do the below thing::

DateInput-ReadOnly="false"
EnableKeyboardNavigation="false"


但是,如果我这样做,则如果用户输入字母或--这样的字符,则会出错.
我希望用户不能自行输入日期,必须从日历中选择日期.


but if i do this then,if the user enters alphabet or Chars like -,/ it is giving error.
I want that user cannot enter the date on its own,he has to pick it from the calender.
any help would be deeply regarded.

推荐答案

<telerik:RadDatePicker ... DateInput-ClientEvents-OnKeyPress="KeyPress">



JavaScript:



JavaScript:

<script type="text/javascript">
  function KeyPress(sender, eventArgs) {
     var keyPressed = eventArgs.get_keyCode();
     if ((keyPressed > 64 && keyPressed < 91)

        || (keyPressed > 96 && keyPressed < 123)) {

         eventArgs.set_cancel(true)

     }

  }

</script>







报价:

请注意,您可以使用示例中显示的ASCII码来禁用其他键盘键.(大写字母为65-90,而97为97 -122(用于小写字母).

Note that you can disable additional keyboard keys by using their ASCII code as showed in the example.(65-90 for capitalized letters and 97-122 for small letters).


这篇关于telerik datepicker删除日期时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:16