有没有办法在HTML中使输入框只接受一个字母?

huangapple go评论48阅读模式
英文:

Is there a way to make an input only accept one letter in HTML?

问题

我正在制作一个HTML版的Wordle复刻,我想为每个字母创建单独的输入,但我不知道如何让输入框只接受一个字母。有没有办法让输入框只接受一个字母?

英文:

I'm working on an Wordle remake in HTML, and I want to make separate inputs for each letter, but I don't know how to make the input only accept one letter. Is there any way to make an input only accept one letter?

答案1

得分: 0

当然可以。使用 maxlength 属性。

<input type="text" maxlength="1">
英文:

Sure you can. Using the maxlength attribute.

<input type="text" maxlength="1">

huangapple
  • 本文由 发表于 2023年6月11日 21:43:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450754.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定