具有“应用”作为前缀,然后在输入字段中仅允许数字

发布于 2025-02-02 03:05:48 字数 246 浏览 2 评论 0原文

我有一个需要输入字段的要求,必须具有前缀“应用程序”,然后允许用户输入仅7个数字值。我希望我可以使用NGX面具,但似乎不可能。另外,我正在考虑使用(焦点)事件,例如:

(focusin)="addPrefix($event)"

inputValue = "";
addPrefix(ev: any){
 inputValue = "APP ";
}

然后有一个键盘事件,如果输入&lt< = 3。建议?谢谢

I have a requirement where I have an input field, that must have the prefix "APP " and then allow the user to type in 7 numeric only values. I was hoping I could use ngx-mask, but it doesn't seem possible. Alternatively I was thinking of using (focusin) event like:

(focusin)="addPrefix($event)"

inputValue = "";
addPrefix(ev: any){
 inputValue = "APP ";
}

and then having a keyup event which would disregard key presses if input.length <= 3.But then comes this issue of pasting values in. Does anyone else have any better ideas/suggestions? Thanks

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

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

发布评论

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

评论(1

看透却不说透 2025-02-09 03:05:48

<input type="text" prefix="APP " mask="0000000" [clearIfNotMatch]="true" />

使用NGX面具?

Stackblitz

How about,

<input type="text" prefix="APP " mask="0000000" [clearIfNotMatch]="true" />

using ngx-mask?

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