Restrict input to positive numbers up to max value only
Hello,
I use an SfNumericEntry so that the user can only enter numbers according to the following specification:
Only positive numbers (Minimum 1) up to 9999 without any grouping sign, e.g. thousands separator
If've setup the control like so:
<input:SfNumericEntry TextColor="White" FontSize="18" AllowNull="False" SelectAllOnFocus="True" CustomFormat="N0" MaximumNumberDecimalDigits="0" Minimum="1" Maximum="9999" />
But I'm still able to input a negative sign
and numbers much higher/lower then specified.
Only when the control loses focus the input is corrected to the max/min value, except that a thousand separator is added.
So, how can I :
1) Avoid that the user can type in values outside of the specified range? In this case the user shouldn't be able to type more than 4 digits
2) Avoid the negative sign?
3) Avoid thousand separator?
Thanks alot for your help!
Regards,
Michael
Hi Michael,
Thank you for your detailed query.
By default, SfNumericEntry validates and formats its value only when the control loses focus, which is why you can temporarily enter negative values or numbers outside the specified range. However, this behavior can be changed by enabling immediate value updates while the control is focused.
This can be achieved using the ValueChangeMode property.
XAML Code :
<input:SfNumericEntry TextColor="White" FontSize="18" AllowNull="False" SelectAllOnFocus="True" Minimum="1" Maximum="9999" MaximumNumberDecimalDigits="0" ShowGroupingSeparator="False" ValueChangeMode="OnKeyFocus" /> |
With this configuration:
- Only positive numbers between 1 and 9999 can be entered
- Negative values are restricted
- Thousand separators are not displayed
- Validation and value updates occur while the control is focused
We hope this addresses your requirements clearly. Please feel free to reach out if you need any additional clarification or a sample project demonstrating this setup.
Regards,
Kishore J
Hi Kishore,
thanks for your reply. Your suggested solution workes fine, except for the thousand separator.
Your XAML code shows a property
ShowGroupingSeparator="False"which doesn't seem to exist in my version 33.2.4.
Am I doing something wrong?
Regards
Michael
Hi Michael,
Sorry for the confusion and any inconvenience caused earlier.
The ShowGroupingSeparator property is not available in the SfNumericEntry. Thank you for pointing this out.
We’ve now updated and shared a corrected sample that demonstrates how to achieve the expected behavior without the thousand separator, using the valid configuration supported in this version. Kindly review the updated sample for reference.
Please feel free to modify the sample to better match your scenario, and let us know if the issue still reproduces. We’ll be happy to investigate further if needed.
Thank you for your understanding.
Regards,
Shyam Sundar D
Attachment: NumericEntrySample_9dabd950.zip
Thanks alot! That solves it.
Regards
Michael
Hi Michael,
You are welcome.
We are glad to know that the reported problem
has been resolved. Please let us know if
you require any further assistance on this. We will be happy to assist you.
Regards,
Preethi R
- 5 Replies
- 4 Participants
-
MI Michael
- May 7, 2026 11:11 AM UTC
- May 12, 2026 04:41 AM UTC