Restrictions on the input block of the input digital containing decimals
obj.value = obj.value.replace (/ [^ \ D.] / G, ""); // Clear "number other than" and "" in character. obj.value obj.value.replace = (/ ^ \ ./g, ""); // verify that the first character is not numeric. obj.value obj.value.replace = (/ \ {2,} / G,. "");. // retain only the first a. remove excess. obj.value = obj.value.replace ( ".", "$ # $"). the replace (/\./ G, ""). the replace ( "$ # $",. " " ); obj.value obj.value.replace = (/ [^ \ D.] / G, '') Replace (/ \ {2,} / ') Replace (/^\./ G,.'.. '.'. '.'. g,) replace (, '$ # $') replace (/\./ g, ''.) replace ( '$ # $', '') ";. // final
HTML uses
<input type="text" oninput = "value=value.replace(/[^\d.]/g,'').replace(/^\./g,'').replace(/\.{2,}/g,'.').replace('.','$#$').replace(/\./g,'').replace('$#$','.')">