test_ifinteger的错误消息

本文关键字:错误 消息 ifinteger test | 更新日期: 2023-09-27 18:10:27

我一直得到这个错误信息:"Microsoft JScript运行时错误:属性'test_ifinteger'的值为空或未定义,不是一个函数对象"

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master"     Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
NZ Currency Converter 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script>
function test_ifinteger(testcontrol, nameoffield) {
    var x = 0;
    var isok1 = true;
    var isok = true;
    var teststring = testcontrol.value;
    if (teststring.length == 0)
        return true;
    if (isNaN(teststring)) {
        isok1 = false;
        alert(nameoffield + " must be a number!");
        testcontrol.focus();
        return isok1;
    }
    else if (teststring < 0) {
        isok = false;
        alert(nameoffield + " must be nonnegative!");
        testcontrol.focus();
        return isok;
    }
            else if 
                        (teststring.CharAt(x) < 0)
                        isok = false;
                        alert(nameoffield + " must be nonnegative!");
                        testcontrol.focus();
                      return isok;
              }
                else if { 
                      while (x < teststring.length) {
                    if (teststring.charAt(x) == '-')
                       isok = false;
                   x++;
               }
               }
             if (!isok1) {
                   alert(nameoffield + " must be a number!");
                    testcontrol.focus();
               } //end else if(ok)
                return isok1;
                else if (!isok) {
                    alert(nameoffield + " must be nonnegative!");
                   testcontrol.focus();
                }
             return isok;
}
</script>
<form name="Currency">
 <tr>
 <td>
   <input type="radio" name="convert" value="fromnzd" checked <%if (String.Compare((String) ViewData["convert"],"Y",false)==0) Response.Write("checked"); %> />Convert From NZD<br />
  <input type="radio" name="convert" value="tonzd" <%if (String.Compare((String) ViewData["convert"],"Y",false)==0) Response.Write("checked"); %> />Convert To NZD
</td>
</tr>
<br /><tr>
<td colspan="2" align="right">&nbsp;&nbsp;The other currency is:</td>
<td>
  <select name="exchrate:">
    <% List<Currency.Models.exchrate> exchrate = (List <Currency.Models.exchrate>) ViewData["exchrate"];
       foreach (Currency.Models.exchrate st in exchrate)
       {
    %>  
     <option value="<% Response.Write(st.othercurrency);%>"><% Response.Write(st.othercurrency);%></option>  
    <% } %>
    <option value=""></option>
  </select
 </td>
 </tr>
 <br />
 <tr><td colspan="2" align="right">&nbsp;&nbsp;You Wish To Convert: <input type="text"  name="calculate" value="<%=ViewData["calculate"]%>" onblur="test_ifinteger (Currency.calculate,'Value')" /><td><input type="submit" name="submitter"  value="Calculate"/></td></td></tr>
  <br /> <tr><td colspan="2" align="right">&nbsp;&nbsp;That Will Produce: <input type="hidden" name="currency" value="<%=ViewData["currency"] %>"/></td></tr>
  </form>
  </asp:Content>

我找不到错误可能是什么。它以前是有效的。请帮助。asp.net新功能

test_ifinteger的错误消息

尝试删除函数调用中的空格:

<input type="text"  name="calculate" value="<%=ViewData["calculate"]%>"   
       onblur="test_ifinteger(Currency.calculate,'Value');" />