入力フォームの数値に3桁ごとにカンマを付ける「maskMoney」
当ページのリンクには広告が含まれています。
スポンサーリンク
入力フォームの数値に3桁ごとにカンマを付けるプラグイン「maskMoney」を紹介します。
jQueryプラグイン「maskMoney」
このプラグインを使えば、伝票の金額入力でよくあるように数値を3桁ごとのカンマで区切ることができます。
123,456,789
こんな感じです。
また、オプションでは「prefix」「suffix」や区切る記号などを指定することができるので、以下のような表示も可能です。
¥ 123,456,789
スポンサーリンク
それではデモページの入力フォームをご覧ください。
デモのソース(HTML + jQuery)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="maskMoney のデモでーす。">
<title>maskMoney - jQuery Plugin Demo</title>
</head>
<body>
<p><a href="https://webkaru.net/jquery-plugin/maskmoney/">「jQueryプラグインまとめ」に戻る</a></p>
<h1>maskMoney のデモです。</h1>
<input type="text" id="demo" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.maskMoney.js"></script>
<script>
$("#demo").maskMoney({
prefix:'¥',
thousands:',',
allowZero: true,
precision: '0'
});
</script>
</body>
</html>
スポンサーリンク