Placing a comma in a user input field when its type is "number" not "text"

I found this last night. Just trying to figure out how to implement it now.

#Commas required
#Cannot be empty
#Pass: (1,000.100), (.001)#Fail: (1000), ()
^(?=.)(\d{1,3}(,\d{3})*)?(\.\d+)?$

link: https://stackoverflow.com/questions/5917082/regular-expression-to-match-numbers-with-or-without-commas-and-decimals-in-text