简体   繁体   English

用于数字和特殊文本的HTML输入-用户友好

[英]HTML input for number and special text - user friendly

In my html form the inputtag is supposed to be a number (so I specify number type), but some numbers have special meanings. 在我的html表单中,inputtag应该是数字(因此我指定数字类型),但是某些数字具有特殊含义。 Like the expiry in days input tag can have any number of days but if user wants to specify No Expiry I expect 0 as input so to convey that I show placeholder text 就像天数到期一样,输入标签可以有任意天数,但是如果用户要指定“ No Expiry我希望输入0 ,以便传达出我显示占位符文本

1, 2, 30, 0 (No Expiry) etc.

It doesn't seem user friendly as input can have some number initially, which hides the message and can confuse the user. 看起来用户友好性不高,因为输入最初可能会有一些数字,这隐藏了消息并可能使用户感到困惑。

Also, I need to take input a number but also allow the user following value: 另外,我需要输入一个数字,但还要允许用户输入以下值:

Unlimited

I don't want user to type this. 我不希望用户键入此内容。 What is best way to handle this? 处理此问题的最佳方法是什么?

Sounds like a dropdown would work if you don't have to use input tag. 如果您不必使用输入标签,则听起来像下拉菜单将起作用。 As you mentioned that you don't want user to type. 正如您提到的那样,您不希望用户键入。 So a simple dropdown would be like this: 因此,一个简单的下拉列表将如下所示:

<select>
  <option value="0">No Expiry</option>
  <option value="Unlimited">Unlimited</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <!-- more option -->
  <option value="3">3</option>
</select>

You can see the effect here: https://jsfiddle.net/nx1Lt86g/ 您可以在这里看到效果: https : //jsfiddle.net/nx1Lt86g/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM