# Problem with Numeric Input and Callback

**URL:** <https://community.plotly.com/t/problem-with-numeric-input-and-callback/14537>\
**Category:** Dash Python\
**Created:** [October 14, 2018, 10:03pm UTC](https://community.plotly.com/t/problem-with-numeric-input-and-callback/14537 "2018-10-14T22:03:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alanm](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@alanm](https://community.plotly.com/u/alanm)\
**Post date:** [October 14, 2018, 10:03pm UTC](https://community.plotly.com/t/problem-with-numeric-input-and-callback/14537/1 "2018-10-14T22:03:50Z")

</div>

I am using an Input Component for numeric input but when I use that component as an input to a callback, problems occur when entering decimal numbers. The Input won’t allow an entry of a zero digit to the right of the decimal point (Try entering 0.01 in the example below). Other oddities occur. Entry is fine when the callback is disabled. Here is code demo’ing the problem:

```python
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash( __name__ , external_stylesheets=external_stylesheets)

app.layout = html.Div(children=[
    html.H1(children='Input Component Bug'),
    html.P([
        'Try to Enter a Fractional Number like 0.01: ', 
        dcc.Input(id='number-input', type='number', inputmode='numeric')
    ]),
    html.P([
        'Mirrored Input: ', 
        html.Span(id='mirrored-number')
    ])
    
])

@app.callback(
    Output(component_id='mirrored-number', component_property='children'),
    [Input(component_id='number-input', component_property='value')]
)
def update_output_div(num):
    return num

if __name__ == ' __main__':
    app.run_server(debug=True)

```

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [October 15, 2018, 3:55pm UTC](https://community.plotly.com/t/problem-with-numeric-input-and-callback/14537/2 "2018-10-15T15:55:32Z")

</div>

For now, I’d keep `type='text'` and then parse the number in your callback (`num = float(num)`). There is an issue here: [https://github.com/plotly/dash-core-components/issues/169](https://github.com/plotly/dash-core-components/issues/169)

---

<div class="post-metadata">

**Author:** ![alanm](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@alanm](https://community.plotly.com/u/alanm)\
**Post date:** [October 16, 2018, 2:27am UTC](https://community.plotly.com/t/problem-with-numeric-input-and-callback/14537/3 "2018-10-16T02:27:11Z")

</div>

That was my backup plan. I read through the issue, and I too would prefer to have the callback triggered with onBlur instead of every keystroke. Hope the fix is coming. Very nice work overall with the product, though! Thank you!

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [October 16, 2018, 3:35pm UTC](https://community.plotly.com/t/problem-with-numeric-input-and-callback/14537/4 "2018-10-16T15:35:18Z")

</div>

> [@alanm](#):
>
> and I too would prefer to have the callback triggered with onBlur instead of every keystroke.

This is coming in [Add `n_blur/n_submit` to Input. by T4rk1n · Pull Request #326 · plotly/dash-core-components · GitHub](https://github.com/plotly/dash-core-components/pull/326)!
