Support

Account

Home Forums General Issues Number field

Solving

Number field

  • Hello all,
    Is it possible to control the number of decimal places a Number field can display within WordPress and on the website front end?

    Many thanks

  • On the front end, not that I know of.

    In the back end you can set the Step Size. If you want to limit input to 2 decimal places set the step size to “0.01”

  • For anyone else wondering …

    I needed to show long decimal latitude and longitude values (e.g. 53.234567) to 2dps on the front end (53.23).

    This worked for me.

    <?php
    
    	$output = get_field('latitude_metric');
    	$latitude = round($output, 2);
    	echo $latitude;
    ?>

    Hope it’s of use.

  • function format_number($number) {
    	return number_format($number, stripos(strrev ($number), '.'), '.', ',');
    }
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Number field’ is closed to new replies.