Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4172

Need an Input to accept decimals and fractions

$
0
0

In my Blazor application, I wonder how I can allow an Input to accept either decimal numbers (e.g. 23.45) or fractions (e.g. 45 3/8)?

E.g. currently I have an Input that takes only decimals:

<InputNumber id="A" @bind-Value="_A" ParsingErrorMessage="A must be a valid number" class="form-control mx-2" />

In code-behind:

        private double? _A;

If a decimal number is provided (e.g. 34 or 34.56), _A should be set to it as it is, and if a fraction is provided, it should be converted to a double. Is there any sample of how this can be achieved?


Viewing all articles
Browse latest Browse all 4172

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>