Function convert (amtstr) {var A, renum = ''; var J = 0; var a1 ='', a2 = '', A3 = ''; vaR tes =/^-/; A = amtstr. replace (/,/g, ""); A =. replace (/[^ -\., 0-9]/g, ""); // Delete invalid character a =. replace (/(^ \ s *) | (\ s * $)/g, ""); // trim if (TES. test (A) a1 = '-'; else a1 = ''; A =. replace (/-/g, ""); if (! = "0" & A. substr (0, 2 )! = "0. ") A =. replace (/^ 0 */g, ""); j =. indexof ('. '); If (j <0) J =. length; a2 =. substr (0, J); a3 =. substr (j); j = 0; for (I = a2.length; I> 3; I = I-3) {renum = "," + a2.substr (I-3, 3) + renum; j ++;} renum = A1 + a2.substr (0, a2.length-J * 3) + renum + A3; return renum ;} /****** convert money *****/function convertmoney () {$ ("[money]"). each (function () {var STR = $ (this ). val (); $ (this ). K Eyup (function (EVT) {STR = $ (this). Val (); EVT = (EVT )? EVT: (window. Event )? Window. Event: "") // compatible with IE and Firefox, get the keyboardevent object var key = EVT. keycode? EVT. keycode: EVT. which; // compatible with IE and Firefox, obtain the key value of the keyboardevent object if (Key >=33 & Key <= 40) {EVT. preventdefault (); EVT. returnvalue = false; return false;} $ (this ). val (convert (STR) ;}); If (STR! = "") {$ (This). Val (convert (STR) ;}}) ;}$ (function (){
Convertmoney ();
});
First introduce the above code, and then add a money attribute to your textbox. The value is any value.
Then you can verify all the money.