Page_Load加入 AMT_txt.Attributes("onkeyup") = "trans_amt('" + AMT_txt.ClientID + "');"
以下為JavaScript 注意JavaScript的replace只取代第一個相同的字串 必須加上/\ /g
function trans_amt(Name) { var amt = document.getElementById(Name).value; var amt_length = amt; amt = amt.replace(/\,/g, ""); re = /(\d{1,3})(?=(\d{3})+(?:$|\D))/g; n1 = amt.replace(re, "$1,"); document.getElementById(Name).value = n1; //var sel = document.selection.createRange(); //sel.moveStart('character', amt_length.length); //sel.collapse(true); //sel.select(); }
沒有留言:
張貼留言