2

我需要只制作一个数字字段integer,以便该字段不接受小数。我什至希望该字段近似,根本不接受点或逗号。

基于文化,它接受数字分隔符(例如 EN 是点,IT 是逗号)

这是我尝试过的代码

$("#numerictextbox").kendoNumericTextBox({
     culture: "en-US",
     step: 500,
     spinners: false,
     format: "#",
     decimals: 0
});
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.3.1023/styles/kendo.common.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.3.1023/styles/kendo.rtl.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.3.1023/styles/kendo.silver.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.3.1023/styles/kendo.mobile.all.min.css"/>

    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.3.1023/js/kendo.all.min.js"></script>
 <script src="https://kendo.cdn.telerik.com/2019.3.1023/js/cultures/kendo.culture.en-US.min.js?bust=v21"></script>
</head>
<body>
  
<input id="numerictextbox" />
</body>
</html>

在这里您可以找到带有意大利文化示例的道场链接,在这种情况下,它会阻止逗号

4

1 回答 1

4

Try using the restrictDecimals configuration option.

$("#numerictextbox").kendoNumericTextBox({
    culture: "en-US",
    step: 500,
    spinners: false,
    format: "#",
    decimals: 0,
    restrictDecimals: true
});

With this configuration a comma and a point with behave like entering a letter(red exclamation flash).

Example

于 2019-10-28T19:04:56.737 回答