英文:
jQuery.inputmask and its placeholder
问题
以下是要翻译的代码部分:
$("input").inputmask("decimal", {
"radixPoint": ",",
"groupSeparator": " ",
"digits": 2,
"autoGroup": true,
"digitsOptional": true,
"suffix": " EUR",
"placeholder": "129,5",
"clearMaskOnLostFocus": false,
})
不好意思,这部分内容已经被您提供的代码本身包含,没有需要额外翻译的内容。
英文:
Here is my code:
$("input").inputmask("decimal", {
"radixPoint": ",",
"groupSeparator": " ",
"digits": 2,
"autoGroup": true,
"digitsOptional": true,
"suffix": " EUR",
"placeholder": "129,5",
"clearMaskOnLostFocus": false,
})
Everything works great but I don't really understand how to display "129,5" as a placeholder instead of "1"?
Thanks in advance for your help!
I tried to search within StackOverflow and read the official documentation for jQuery.inputmask, but it didn't help.
答案1
得分: 1
以下是翻译好的部分:
文档中的输入掩码插件包含了有关设置初始值的部分。
它指出你只需设置输入的value
属性。
你可以在HTML中这样做,例如:<input value="129,5">
或者,你也可以使用jQuery来实现:
$(function () {
$("input")
.val("129,5")
.inputmask("decimal", {
"radixPoint": ",",
"groupSeparator": " ",
"digits": 2,
"autoGroup": true,
"digitsOptional": true,
"suffix": " EUR",
"clearMaskOnLostFocus": false,
});
});
英文:
The docs for the inputmask plugin contain a section on Setting Initial Values.
It states that you just need to set the value
attribute of the input.
You could do this in HTML, ex: <input value="129,5">
Alternatively, you could do it with jQuery:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$(function () {
$("input")
.val("129,5")
.inputmask("decimal", {
"radixPoint": ",",
"groupSeparator": " ",
"digits": 2,
"autoGroup": true,
"digitsOptional": true,
"suffix": " EUR",
"clearMaskOnLostFocus": false,
});
});
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/inputmask@5.0.8/dist/jquery.inputmask.min.js"></script>
<input>
<!-- end snippet -->
答案2
得分: 0
我查看了 jQuery.inputmask 的源代码,并了解到没有办法处理它,所以我不得不寻找不同的方法。
英文:
I looked through jQuery.inputmask source codes and understood that there's nothing to do about it so I had to find out different approach.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论