Event Onblur,onfocus
1<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">234<title>javascript text box thousand-bit practice </title>5<script type= "Text/javascript" >6 functionCommafy (n) {7 varRe =/\d{1,3} (? = (\d{3}) +$)/g;//match number of digits8 varN1 = N.replace (/^ (\d+) ((\.\d+)?) $/,function(s, s1, S2) {returnS1.replace (Re, "$&,") +S2;});9 returnN1;Ten } One functionAddthousand () { A varTxtbox = document.getElementById ("txtID"); -Txtbox.value =Commafy (txtbox.value); - } the functionRemovethousand () { - varTxtbox = document.getElementById ("txtID"); -Txtbox.value= TxtBox.value.replace (/,/g, ""); - } +</script> - +<body> A<input id= "txtID" onblur= "Addthousand ()" onfocus= "Removethousand ()" type= "text" style= "Text-align:right;ime-mode :d isabled "/> <label for=" txtID "> Thousand points Exercise </label> at</body> -View Codetext box thousands of bits