I'm trying to set up a way to prevent inputs into certain fields in JavaScript. Most of my fields check against /^\d*$/.test(value) which will prevent any input from being typed in or shown that's non-numeric.
One particular field uses /^[\d.]*$/.test(value) which allows any number of digits and a decimal to be placed in as well.
My issue is that the decimal regex allows any number, or combination specifically, of decimals to be input. I'm trying to prevent inputs like "....", "13.24..36", ".2.2", etc.
Could anyone provide a regex that has to start with a number, end with a number, can have decimal or no decimal, and prevents two decimals being put together? (like .. <- preventing the second unless another number follows)
/^\d*(?:\.\d+)?$/