数値のみ入力可能なフォームを実装するプラグイン「Numeric Input」を紹介します。
jQueryプラグイン「Numeric Input」
このプラグインを使えば、指定した input要素の入力を制御し、数値だけしか入力できないようにすることができます。
オプションでは正/負の入力可否、小数点を含む/含まないといった数値に関する制御を設定することができます。
それではデモページを編集してみてください。
「Numeric Input」のデモ
デモのソース(HTML + jQuery)
< meta name = "description" content = "Numeric Input のデモでーす。" > |
< title >Numeric Input - jQueryプラグイン</ title > |
< h1 >Numeric Input のデモ。</ h1 > |
< p >整数(…,-3,-2,-1,0,1,2,3…)のみ入力可能です。</ p > |
< p >< input type = "text" id = "demo" /></ p > |
< script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></ script > |
< script src = "numericInput.js" ></ script > |
$(document).ready(function() { |
$("#demo").numericInput({ |
jsファイルのダウンロード、オプション詳細はこちらからどうぞ。