// The value in the text box that determines the input subtotal amount can only be a number or a decimal number $ (function () {$. fn. numeral = function () {publish (this).css ("ime-mode", "disabled"); this. bind ("keypress", function (e) {var code = (e. keyCode? E. keyCode: e. which); // compatible with Firefox IE if (! $. Browser. msie & (e. keyCode = 0x8) // The return key {return;} return code >=48 & code <= 57 | code = 46;} cannot be used under Firefox ;}); this. bind ("blur", function () {if (this. value. lastIndexOf (". ") = (this. value. length-1) {this. value = this. value. substr (0, this. value. length-1);} else if (isNaN (this. value) {this. value = "" ;}}); this. bind ("paste", function () {var s = clipboardData. getData ('text'); if (! /\ D /. test (s); value = s. replace (/^ 0 */, ''); return false ;}); this. bind ("dragenter", function () {return false ;}); this. bind ("keyup", function () {this. value = this. value. replace (/[^ \ d.] /g, ""); // The first one must be a number instead of a number. this. value = this. value. replace (/^ \. /g, ""); // ensure that only one exists. no. this. value = this. value. replace (/\. {2,}/g ,". "); // guarantee. only appears once, but not more than twice this. value = this. value. replace (". "," $ # $ "). replace (/\. /g ,""). replace ("$ # $ ",". ") ;};};$ (" # id of the number or decimal text box "). numeral () ;}); share: