-2
在以下jquery
調用表單提交時,出現以下錯誤。有一些帖子在網上的錯誤,但由於某種原因,我還沒有什麼我可能在下面的jQuery代碼缺少明確:JQuery TypeError - Callback.call不是函數
錯誤:
TypeError: callback.call is not a funtion
注意:
- 雖然這是一個jQuery錯誤,但我添加了錯誤的詳細信息,以顯示我正在使用哪個jQuery版本和庫。當您在Visual Studio 2015中創建ASP.NET Core MVC項目時,它是jQuery的內置配置。
- 輸入顯示貨幣值爲
$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>
}
以及每個人都應該有它的功能.... – epascarello
你'$(本)'是指'$( '#myForm的') ',而不是每個'$('。inputclass')' –