For 2 of my custom fields, I'm using Regular Expression to make sure they are formatted correctly, and that members can't take the piss with them (BHP and Torque)
For this, I'm limiting them to < 999.99 bhp and lb/ft and they can enter upto 2 decimal places, or whole number
This is the regex I'm using:
^ - start of anchor
\d - Numbers
{2,3} - between 2 and 3 numbers in length
\.? - escaped the decimal place, and set it as optional with ?
\d{0,2}? - 2 numbers after decimal place and also set optional with ?
$ - end of string anchor
For this, I'm limiting them to < 999.99 bhp and lb/ft and they can enter upto 2 decimal places, or whole number
This is the regex I'm using:
Code:
^\d{2,3}\.?\d{0,2}?$
^ - start of anchor
\d - Numbers
{2,3} - between 2 and 3 numbers in length
\.? - escaped the decimal place, and set it as optional with ?
\d{0,2}? - 2 numbers after decimal place and also set optional with ?
$ - end of string anchor