ShowMaskonFocus在Angular中不适用于输入蒙版

发布于 2025-01-18 23:07:35 字数 408 浏览 0 评论 0原文

我正在使用输入蒙版库,并希望实现时间格式的掩码。 它将接受HH:MM格式中的整数数字,因此以下面的形式使用它

timeInputMask = createMask({
    mask: '[99:99]',
    showMaskOnFocus: true,
    showMaskOnHover:true
  });

<input maxlength="5" placeholder="__:__" [inputMask]="timeInputMask" />

在加载文本框默认掩码后, 为“ ”,因此其工作正常。 问题是 - 一旦我单击文本框,掩码就隐藏了即文本框是空白的。开始键入编号后,掩码再次出现。

您知道我们如何使掩盖在He Textbox的焦点上可见吗?

I am using input-mask library and wanted to implement masking for time format. Which will accept integer numbers in HH:mm format so used this as below

timeInputMask = createMask({
    mask: '[99:99]',
    showMaskOnFocus: true,
    showMaskOnHover:true
  });

<input maxlength="5" placeholder="__:__" [inputMask]="timeInputMask" />

After loading a textbox default masking is coming as ":" so its working fine.
Problem is - as soon as I click inside the textbox, the masking is hiding i.e. text box is blank. After starts typing number the mask appears again.

Do you know how can we make masking visible on focus of he textbox?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你列表最软的妹 2025-01-25 23:07:35

这里我使用 https://github.com/ngneat/input-mask 库。

*.html

<input maxlength="5" placeholder="HH:MM" [inputMask]="time" />

*.ts

time = createMask<Date>({
    alias:'datetime',
    inputFormat: 'HH:MM'
  });

参考: https: //stackblitz.com/edit/angular-ivy-sp6w7d?file=src%2Fapp%2Fapp.component.html

Here i use https://github.com/ngneat/input-mask library.

*.html

<input maxlength="5" placeholder="HH:MM" [inputMask]="time" />

*.ts

time = createMask<Date>({
    alias:'datetime',
    inputFormat: 'HH:MM'
  });

Ref: https://stackblitz.com/edit/angular-ivy-sp6w7d?file=src%2Fapp%2Fapp.component.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文