HTML5 Input for Currency Format

Best way I could find to accept currency format in an input field. To use regex pattern, input field must be type="text" instead of type="number". Noticed that commas seem to get submitted in a funny way if either type="text" or type="number" is set (submitted as HTML-encoded values)

HTML

Experiment to see how to use HTML5 input field of type="number" for input such as USD/CDA dollar currency amount (with an optional 2-precision decimal place for cents). Using type="number" defaults most mobile users' digital keypad to a numeric keypad for entry, and so it is more ideal that using input type="text" with a RegEx pattern to allow entry for cents.
    
    <br /><br />

<form action="#">    
<fieldset>
    <legend>Tests for input field that allows decimal for CDA/USD dollar curreny format</legend>
    
    Regular numeric input: $<input type="number" name="currency" min="1" max="9999" size="4" 
 title="CDA Currency Format - no dollar sign, no comma(s) and no cents (.##) are allowed" />
    <br />* this does not allow entry of cents. Non-numeric values are automatically discarded on the input field's change event.
    <br /><br />
    
    Text input with RegEx: $<input type="text" name="currency" pattern="^\d*(\.\d{2}$)?" size="4"
    title="CDA Currency Format - no dollar sign and no comma(s) - cents (.##) are optional" />
    <br />* if type="number" then RegEx pattern cannot be used, however it can be used with type="text" to allow 2-precision decimal place. This is the only way to enfore true, 2-precision decimal place entry in an input field (decimal place value is optional, but if used then it must be 2-precision).
    <br /><br />
    
    Numberic input with decimal: $<input type="number" name="currency" min="0" max="9999" step="0.01" size="4" 
    title="CDA Currency Format - no dollar sign and no comma(s) - cents (.##) are optional" />
    <br />* setting step="0.01" is the only way to enforce decimal on an input field of type="number" (note: 1-precision decimal place (.1) will be allowed). Non-numeric values are automatically discarded on the input field's change event.
    <br /><br />
            
    Double numeric input: $<input type="number" name="currencyDollars" min="0" max="9999" size="4"
    title="Only numbers are allowed" />
   ...