javascript运行不正常

时间:2015-08-04 08:14:03

标签: javascript asp.net

我的javascript函数有问题。 我有一个文本框,不应该接受其他字符只是基于其他下拉列表的数字。 对于第一个条件(“Leternjoftimi”)它工作正常,但对于第二个“Numri i biznesit”我不工作。 有帮助吗? 我的功能如下:

<script type="text/javascript">
    function isNumber(evt) {
       evt = (evt) ? evt : window.event;
       var charCode = (evt.which) ? evt.which : evt.keyCode;
       var doctype = document.getElementById("ctl00_DefaultContent_FormViewPerson_txtIdType");
       var test = document.getElementById("ctl00_DefaultContent_FormViewPerson_txtIdType1");
       if (charCode > 31 && (charCode < 48 || charCode > 57) && (doctype.value == "Leternjoftimi" || test.value == "Numr i biznesit")) {
           return false;
       }
       return true;
    }   
</script>
 <asp:TextBox ID="TextBoxIDCode" runat="server" Width="100%" Text='<%# Bind("IDCode") %>' AutoPostBack="true" meta:resourcekey="TextBoxIDCodeResource1" onkeypress="return isNumber(event);" ></asp:TextBox>

列表的asp.net代码应该是基础:

<asp:TextBox ID="txtIdType" runat="server" AutoPostBack="true" Width="100%" meta:resourcekey="txtIdTypeResource1" AutoCompleteType="None" OnTextChanged="txtIdType_TextChanged"  ></asp:TextBox>
<asp:TextBox ID="txtIdType1" runat="server" AutoPostBack ="true" Width="100%" meta:resourcekey="txtIdTypeResource1" AutoCompleteType="None" OnTextChanged="txtIdType1_TextChanged"  ></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtenderIdType" runat="server"
  CompletionInterval="200" 
  MinimumPrefixLength="0" 
  CompletionListCssClass="listMain"
  CompletionListItemCssClass="itemsMain"
  CompletionListHighlightedItemCssClass="itemsSelected"
  OnClientItemSelected="IdTypeSelected"
  ServiceMethod="GetDIVRList_IdType" 
  ServicePath="~/WebServices/AutoCompleteDictionary.asmx"
  TargetControlID="txtIdType" DelimiterCharacters="" Enabled="True">
</ajaxToolkit:AutoCompleteExtender>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1"  runat="server"
  CompletionInterval="200" 
  MinimumPrefixLength="0" 
  CompletionListCssClass="listMain"
  CompletionListItemCssClass="itemsMain"
  CompletionListHighlightedItemCssClass="itemsSelected"
  OnClientItemSelected="IdTypeSelected"
  ServiceMethod="GetDIVRList_IdType1" 
  ServicePath="~/WebServices/AutoCompleteDictionary.asmx"
  TargetControlID="txtIdType1" DelimiterCharacters="" Enabled="True">
</ajaxToolkit:AutoCompleteExtender>

0 个答案:

没有答案