带有货币符号的 HTML 文本输入字段 [英] HTML text input field with currency symbol

查看:47
本文介绍了带有货币符号的 HTML 文本输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个一开始就包含$"符号的文本输入字段,并且无论对该字段进行什么编辑,都可以使该符号保持不变.

I would like to have a text input field containing the "$" sign in the very beginning, and no matter what editing occurs to the field, for the sign to be persistent.

如果只接受数字输入我会很好,但这只是一个花哨的补充.

I would be good if only numbers were accepted for input, but that's just a fancy addition.

推荐答案

考虑使用带边框围绕无边框输入字段的跨度模拟具有固定前缀或后缀的输入字段.这是一个基本的启动示例:

Consider simulating an input field with a fixed prefix or suffix using a span with a border around a borderless input field. Here's a basic kickoff example:

.currencyinput {
    border: 1px inset #ccc;
}
.currencyinput input {
    border: 0;
}

<span class="currencyinput">$<input type="text" name="currency"></span>

这篇关于带有货币符号的 HTML 文本输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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