         window.onload = attachEvents;

        function attachEvents() {
            document.getElementById('formazott_szam').onkeyup = reformatNumber;
        }

        function reformatNumber() {
            // No error checking. Assumes only ever 1 DP per number
            var text = this.value.replace(/[^0-9]/g, '');

            // Strip off anything to the right of the DP
            var rightOfDp = '';
            var dpPos = text.indexOf('.');
            if (dpPos != -1) {
                rightOfDp = text.substr(dpPos);
                text = text.substr(0, dpPos);
            }

            var leftOfDp = '';
            var counter = 0;
            // Format the remainder into 3 char blocks, starting from the right
            for (var loop=text.length-1; loop>-1; loop--) {
                var char = text.charAt(loop);

                // Ignore existing spaces
                if (char == ' ') continue;

                leftOfDp = char + leftOfDp;
                counter++;
                if (counter % 3 == 0) leftOfDp = ' ' + leftOfDp;
            }

            // Strip leading space if present
            if (leftOfDp.charAt(0) == ' ') leftOfDp = leftOfDp.substr(1);

            this.value = leftOfDp + rightOfDp;

        }

		// this.value=this.value.replace(/[^0-9]/g, '')
