Jquery plugins jqueryautonumeric插件:希望从空白字段中获取null,但它会自动填充为零

Jquery plugins jqueryautonumeric插件:希望从空白字段中获取null,但它会自动填充为零,jquery-plugins,Jquery Plugins,自动数值插件会在字段聚焦或悬停时立即用零填充输入字段。我想让最终用户将一些字段留空。空白与零不同。有什么解决方案吗?检查AutoNumericOptions.js文件中emptyInputBehavior选项的文档: 您想要的是将emptyInputBehavior设置为默认值“focus”,并且不会在输入中添加任何“零”。 这是下一个版本的v4。在我的用例中,将emptyInputBehavior设置为“null”有效: 这样,当输入字段为空时,其值设置为null /* Defines wha

自动数值插件会在字段聚焦或悬停时立即用零填充输入字段。我想让最终用户将一些字段留空。空白与零不同。有什么解决方案吗?

检查AutoNumericOptions.js文件中emptyInputBehavior选项的文档:

您想要的是将emptyInputBehavior设置为默认值“focus”,并且不会在输入中添加任何“零”。
这是下一个版本的v4。

在我的用例中,将emptyInputBehavior设置为“null”有效:

这样,当输入字段为空时,其值设置为null

/* Defines what should be displayed in the element if the raw value is an empty string ('').
 * - 'focus'  : The currency sign is displayed when the input receives focus (default)
 * - 'press'  : The currency sign is displayed whenever a key is being pressed
 * - 'always' : The currency sign is always displayed
 * - 'zero'   : A zero is displayed ('rounded' with or without a currency sign) if the input has no value on focus out
 * - 'null'   : When the element is empty, the `rawValue` and the element value/text is set to `null`. This also allows to set the value to `null` using `anElement.set(null)`.
 */
emptyInputBehavior: {
    null  : 'null',
    focus : 'focus',
    press : 'press',
    always: 'always',
    zero  : 'zero',
},
emptyInputBehavior: 'null'