[英]How to apply AutoNumeric to all selectors?
类别:浮动
在此示例中,AutoNumeric仅适用于float
类的第一个元素输入。
<script src = "https://unpkg.com/autonumeric" ></script> <form> <input type="text" class="form-control cell-in-text float" id="26" asp-for="@Model.ListEtpAnswer.ElementAt(26).Answer" /> <br /> <input type="text" class="form-control cell-in-text float" id="27" asp-for="@Model.ListEtpAnswer.ElementAt(27).Answer" /> <br /> <input type="text" class="form-control cell-in-text float" id="28" asp-for="@Model.ListEtpAnswer.ElementAt(28).Answer" /> <br /> <script> const autoNumericOptions = { allowDecimalPadding: "floats", decimalCharacter: ",", digitGroupSeparator: "", //emptyInputBehavior: "zero", watchExternalChanges: true }; new AutoNumeric(".float", autoNumericOptions); </script>
您需要使用Autonumeric.multiple一次将其应用于多个元素。
<script src = "https://unpkg.com/autonumeric" ></script> <form> <input type="text" class="form-control cell-in-text float" id="26" asp-for="@Model.ListEtpAnswer.ElementAt(26).Answer" /> <br /> <input type="text" class="form-control cell-in-text float" id="27" asp-for="@Model.ListEtpAnswer.ElementAt(27).Answer" /> <br /> <input type="text" class="form-control cell-in-text float" id="28" asp-for="@Model.ListEtpAnswer.ElementAt(28).Answer" /> <br /> <script> const autoNumericOptions = { allowDecimalPadding: "floats", decimalCharacter: ",", digitGroupSeparator: "", //emptyInputBehavior: "zero", watchExternalChanges: true }; AutoNumeric.multiple(".float",null, autoNumericOptions); </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.