在数字输入中强制引导零

编程入门 行业动态 更新时间:2024-10-27 14:28:35
本文介绍了在数字输入中强制引导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在写一个闹钟网络应用程序。我有两个号码输入,一个是小时,一个是分钟。因此,当我使用我的键盘箭头时,它们从0到23/59。有没有一种HTML原生的方式,使他们从00(01,02等)到23/59而不是?

我只关心UI方面因为我的JS管理丢失的0。

编辑 - 根据要求:

我有:

p>

我想要的:

从0,1,2到59,我想在数字小于10(00,01,

解决方案

恐怕除非使用Select标签,否则没有原生的HTML方法。如果您使用的是文本输入,则必须通过javascript在10个第一个值上添加前导0。

I'm writing an alarm web app. I have two number inputs, one for the hours, one for the minutes. Thus, when I use my keyboard arrows, they go from 0 to 23/59. Is there an HTML native way to make them go from 00 (01,02, et.) to 23/59 instead ?

I'm only worried about the UI aspects as my JS manages the missing 0 anyway.

EDIT - As requested :

What I have :

What I want :

Instead of going from 0,1,2 to 59, I'd like to automatically have a leading 0 when the number is smaller than 10 (00,01,02 to 59).

解决方案

I'm afraid there is not native HTML way to do that unless using a Select tag. If you are using a text input you have to add the leading 0 on the 10 first values by javascript.

更多推荐

在数字输入中强制引导零

本文发布于:2023-11-23 14:54:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!