Formatting dollars for a check

Enter an amount   (e.g. 1234 or 1234567.25) maximum integers 7, no commas
 

This page uses Javascript I wrote for a project I was working on where a dollar amount is entered to be put on a check. When I started coding it I didn't realize how extensive it would get. It's very repetitious using the substring() method so it didn't require a lot of problem solving.