jquery-plugins - jquery autonumeric 插件 : want to get null from blank fields, 但它会自动填充零

标签 jquery-plugins

“autoNumeric”插件会在字段获得焦点甚至悬停时立即用零填充输入字段。我想让最终用户将某些字段留空。空白不等于零。有什么解决办法吗?

最佳答案

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

/* 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 设置为 'focus'(这是默认设置),并且您不会在输入中添加任何“零”。 这是 next 中的版本 v4

关于jquery-plugins - jquery autonumeric 插件 : want to get null from blank fields, 但它会自动填充零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44892819/

相关文章:

javascript - 在行上单击根据该行中单元格的内容禁用/启用按钮

javascript - 仅更改 jquery 插件中的一种选择样式

javascript - 组件返回失败代码: 0x80600011 [nsIXSLTProcessorObsolete.transformDocument]

jquery - 适合移动设备的 jQuery slider ,无需捆绑整个移动库?

javascript - Bootstrap 与 jQuery 自定义内容滚动条

jquery - CSS 水平滚动溢出与 jQuery slider

jquery - 添加指向句子中某个单词的链接

jquery - 需要帮助获取nestedSortable jQuery 的输出

javascript - 如何获得星级评定的值(value),jQuery

jquery - 如何更改 Magnific Popup 中的 CSS 属性