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

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

问题描述

我希望在一开始就有一个包含$符号的文本输入字段,并且无论该字段发生了什么编辑,该符号都是持久的。



如果只有数字被接受用于输入,我会很好,但这只是一个奇特的增加。

考虑一下 使用具有无边界输入字段边界的跨度模拟具有固定前缀或后缀的输入字段。以下是一个基本的启动示例:

<预类= 片段码-CSS琅CSS prettyprint-越权> .currencyinput {边界:1px的插图#CCC ;}。currencyinput input {border:0;}

< ; span class =currencyinput> $< input type =textname =currency>< / span>


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天全站免登陆