加号html输入type = number [英] plus sign in html input type=number

查看:143
本文介绍了加号html输入type = number的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否有可能在html input type = number字段中添加加号吗?我有一种情况,用户需要输入一个+1到+10或-1到-10的修饰符值.我想向用户明确指出他们的输入值会增加结果值.因此,如果在输入的正值前面加上一个+号,那就太好了.

Does anyone know if it's possible to add a plus sign in a html input type=number field? I have a scenario whereby users need to enter a modifier value which is either +1 to +10 or -1 to -10. I want to make it very explicit to the user that their inputted value increments the resulting value. therefore it would be great if a + sign is prepended to a positive inputted value.

我以Angular2反应形式使用此输入,并具有自举样式.因此欢迎使用Angular2指令,boostrap风格甚至是jquery解决方案

I'm using this input in an Angular2 reactive form with bootstrap styling. so an Angular2 directive, a boostrap style or even a jquery solution are welcome

到目前为止,我所看到的是关于在窗体控件中添加货币符号或关于添加+和减号按钮以增加或减少该值.但这不是我想要的,所以我怀疑这是否可能.

What I've seen so far is about adding currency symbols inside the form control or about adding + and minus buttons to increment and decrement the value. But that's not what I want, so I doubt if this is possible at all.

推荐答案

我认为无法操纵输入. 默认为负号,负号为正号.

I don't think it is possible to manipulate the input. the default is a "-" for negative and no sign for positive numbers.

即使您选中了创建UI框架,例如:

even if you checked a create UI frameworks like:

jQuery UI,Bootstrap,Angular Material ...

Jquery UI, Bootstrap, Angular Material ...

我想唯一的解决方案是编写您自己的自定义代码.

I guess the only solution is to write your own custom code.

有两种方案:

1-带有文本的输入,并且操作将使用javascript.

1- an input with Text and the manipulating will be in javascript.

2-在angular2中创建管道并将其提供给元素.我认为这比第一个要容易得多.

2- create a pipe in angular2 and give it to the element. which I think it is much easier than the first one.

这篇关于加号html输入type = number的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆