<p>Just tested this on a local Craft3 setup and here's what I discovered...</p>

<p>If the <code>decimal points</code> setting on the number field is set to <code>0</code>, adding text in the number field will display the pretty errors below:</p>

<p><a href="https://i.sstatic.net/h5vkx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/h5vkx.png" alt="enter image description here"></a></p>

<p>If the <code>decimal points</code> setting is set to anything else, you get the Twig error mentioned in the title of this post:</p>

<blockquote>
  <p>number_format() expects parameter 1 to be float, string given</p>
</blockquote>

<p>I'd recommend opening an issue in the <a href="https://github.com/craftcms/cms/issues?q=is%3Aissue%20is%3Aopen%20sort%3Aupdated-desc" rel="nofollow noreferrer">Craft CMS repo</a> as I imagine the number field ought to display the pretty errors no matter if <code>decimal points</code> is set or not.</p>

CC BY-SA 4.0
2018-10-31T15:46:55.193Z
Issue is here for anyone else reading this thread. https://github.com/craftcms/cms/issues/3416
Chattervast
CC BY-SA 4.0
2018-10-31T15:30:56.010Z
2018-10-31T15:30:56.010Z
Jalen Davenport
<p>Craft 3 is giving me this error when my client enters non-numeric characters into a number field on an entry:</p>

<blockquote>
  <p>number_format() expects parameter 1 to be float, string given</p>
</blockquote>

<p>Is there a way for it to check and remove non-numeric characters from the field on save? Or maybe my setup is incorrect?</p>

CC BY-SA 4.0
2018-10-31T15:22:15.390Z
Is it an error or an exception? Because it actually should display errors rather than removing the characters. You could create a custom field that strips all letters from the input
Robin Schambach
CC BY-SA 4.0
2018-10-31T15:25:46.690Z
Per an image my client sent: PHP Warning - yii\base\ErrorException
Chattervast
CC BY-SA 4.0
2018-10-31T15:26:33.660Z
Shouldn't craft handle this natively? Either not allowing non-numeric characters in number fields or something?
Chattervast
<craft3><entry><field><number>
Non-numeric characters in number field producing errors
# Non-numeric characters in number field producing errors

(Asked by: username_0 on 2018-10-31)

Craft 3 is giving me this error when my client enters non-numeric characters into a number field on an entry:

> number\_format() expects parameter 1 to be float, string given

Is there a way for it to check and remove non-numeric characters from the field on save? Or maybe my setup is incorrect?

**Tags:** craft3, entry, field, number
> **Comments:**
> **username_1**: Is it an error or an exception? Because it actually should display errors rather than removing the characters. You could create a custom field that strips all letters from the input  
> **username_0**: Per an image my client sent: PHP Warning - yii\base\ErrorException  
> **username_0**: Shouldn't craft handle this natively? Either not allowing non-numeric characters in number fields or something?  

---

## 1 answers

### Answer by username_2 on 2018-10-31. Score: 3 | Accepted answer

Just tested this on a local Craft3 setup and here's what I discovered...

If the `decimal points` setting on the number field is set to `0`, adding text in the number field will display the pretty errors below:

[![enter image description here](https://i.sstatic.net/h5vkx.png)](https://i.sstatic.net/h5vkx.png)

If the `decimal points` setting is set to anything else, you get the Twig error mentioned in the title of this post:

> number\_format() expects parameter 1 to be float, string given

I'd recommend opening an issue in the [Craft CMS repo](https://github.com/craftcms/cms/issues?q=is%3Aissue%20is%3Aopen%20sort%3Aupdated-desc) as I imagine the number field ought to display the pretty errors no matter if `decimal points` is set or not.

> **Comments:**
> **username_0**: Issue is here for anyone else reading this thread. https://github.com/craftcms/cms/issues/3416  

---

