function numberFormat(nStr){ nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) x1 = x1.replace(rgx, '$1' + ',' + '$2'); return x1 + x2; } function stripNonNumeric( str ){ str += ''; var rgx = /^\d|\.|-$/; var out = ''; for( var i = 0; i < str.length; i++ ){ if( rgx.test( str.charAt(i) ) ){ if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) || ( str.charAt(i) == '-' && out.length != 0 ) ) ){ out += str.charAt(i); } } } return out; } function serbestpiyasaHesapla(){ miktar = stripNonNumeric($('#serbestpiyasaMiktar').val()); kur1 = $('#serbestPiyasaKur1').val(); kur2 = $('#serbestPiyasaKur2').val(); carpan = miktar / kur2; tutar = carpan * kur1; $('#serbestpiyasaMiktar').val(numberFormat(miktar)); $('#serbestpiyasaTutar').val(numberFormat(tutar.toFixed(2))); } $(document).ready(function (){ $('.h1gizli').hide(); });