JQuery TypeError - Callback.call不是函数

JQuery TypeError - Callback.call不是函数

问题描述:

在以下jquery调用表单提交时,出现以下错误。有一些帖子在网上的错误,但由于某种原因,我还没有什么我可能在下面的jQuery代码缺少明确:JQuery TypeError - Callback.call不是函数

错误

TypeError: callback.call is not a funtion 

注意

  1. 虽然这是一个jQuery错误,但我添加了错误的详细信息,以显示我正在使用哪个jQuery版本和库。当您在Visual Studio 2015中创建ASP.NET Core MVC项目时,它是jQuery的内置配置。
  2. 输入显示货币值为$15,406.15等,我试图从输入之前删除$,表格已提交。

错误详细信息

TypeError: callback.call is not a function at Function.each (http://localhost:50507/lib/jquery/dist/jquery.js:365:19) at jQuery.fn.init.each (http://localhost:50507/lib/jquery/dist/jquery.js:137:17) at HTMLFormElement.<anonymous> (http://localhost:50507/ControlleName:203:36) at HTMLFormElement.dispatch (http://localhost:50507/lib/jquery/dist/jquery.js:4737:27) at HTMLFormElement.elemData.handle (http://localhost:50507/lib/jquery/dist/jquery.js:4549:28) 

查看:

<form id="myform" asp-controller="CustOrders" asp-action="ProductPrices" method="post"> 
.... 
<tr> 
<td>Item1:</td> 
<td><input asp-for="item1_price" asp-format="{0:C}" class="inputclass" /></td> 
</tr> 
<tr> 
    <td>Item2:</td> 
    <td><input asp-for="item2_price" asp-format="{0:C}" class="inputclass" /></td> 
</tr> 
... 
<tr> 
    <td>Item9:</td> 
    <td><input asp-for="item9_price" />></td> 
</tr><tr> 
    <td>Item1:</td> 
    <td><input asp-for="item1_price" asp-format="{0:C}" class="inputclass" /></td> 

</table> 
<button type="submit" name="submit" value="Add">Update Report</button> 
</form> 

@section scripts 
{ 
    <script> 
     $(document).ready(function() { 
      $("#myform").submit(function() { 
       $('.inputclass').each($(this).val($(this).val().replace(/[$,]/g, ''))); 
      }); 
     }); 
    </script> 
} 
+3

以及每个人都应该有它的功能.... – epascarello

+0

你'$(本)'是指'$( '#myForm的') ',而不是每个'$('。inputclass')' –

您使用的每个是错误的。每个人都应该有一个功能

$('.inputclass').each($(this).val($(this).val().replace(/[$,]/g, ''))); 

应该

$('.inputclass').each(function(){ 
    $(this).val($(this).val().replace(/[$,]/g, '')) 
});