Current filter:
                                You should refresh the page.
                                  • Hi,
                                    I attached the document for more details and video for expected behaviour.
                                    Thanks

                                1 Solution

                                Creation Date Importance Sort by

                                Hi,

                                Handle the dxNumberBox.onKeyDown event to implement a custom behavior. For example, refer to the T632118: NumberBox - Can not delete decimal point ticket where we have illustrated a similar scenario. In your particular scenario, you can use the following logic to allow the "-" sign only when the cursor is placed to the editor's start position:

                                [JavaScript]
                                onKeyDown: function(e) { if (e.event.key == "-") { var selPos1 = e.event.target.selectionStart; var selPos2 = e.event.target.selectionEnd; if (selPos1 != 0 || selPos2 != 0) { e.event.preventDefault(); e.event.stopImmediatePropagation(); } } }

                                Here is the modified code example: https://codepen.io/Alex969/pen/RwwXjpX. Although this sample targets the classic jQuery library, the same logic is valid for Angular and other platforms because our components share a common code base. If this does not help you, please modify the sample to illustrate the issue.

                                See Also:
                                NumberBox - It is impossible to enter 0 if the "#" mask is used

                                Thanks,
                                Alessandro

                                Show all comments
                                • Agus W 12.02.2019

                                  Thanks for the answer Alessandro. For now, I have the new issues.

                                  First issues
                                       Current Behaviour:
                                       when use format: #,##0.##, if I press minus sign(-) the result is: -0. how to remove the zero number?

                                       Expected Behaviour:
                                       when use format: #,##0.##, if I press minus sign(-) the result is only - (minus sign)

                                  Second Issues
                                       Current Behaviour:
                                  For delete '-0' , I use simple function like this:

                                  [JavaScript]
                                  onKeyDown(args) { const TargetValue = args.event.target.value; if (args.event.key === 'Backspace' || args.event.key === 'Delete') { if TargetValue === '-0' || TargetValue === '0') { args.component.option('value', null); } } }

                                  But, if I press minus sign again, the minus sign is not appear while minimum & maximum value is minus.
                                  for example [min]='-34.20' and [max] = '-0.50' .

                                      Expected Behaviour:
                                      If I remove the '-0' , and then press minus again.. the minus sign is appear when minimum & maximum value is minus

                                  Thanks

                                • Alessandro (DevExpress Support) 12.03.2019

                                  Hi,

                                  1) The '0' format specifier indicates that the numeric symbol should be always displayed in the editor (see Custom Format String). You can remove it from the format string.
                                  2) If both the min and max option values are less than zero (0), the end-user should not be able to enter "0" or "-0". Would you please clarify how you entered one of these values by using the https://codepen.io/Alex969/pen/KKwKOpW example?

                                • Agus W 12.03.2019

                                  Thank Alessandro.

                                  1. so if I use format: #,##0.##, I can't remove the zero? is there an alternative solution?
                                  2. for this, I expected user can enter minus only (-) after removing the maximum & minimum value
                                • Alessandro (DevExpress Support) 12.04.2019

                                  Hi,

                                  Both issues will be fixed if you remove zero from the custom format: "#,##.##". Would you please clarify why you need to keep zero in the format string and remove it from the editor?

                                • Agus W 12.04.2019

                                  Hi,

                                  Because my QA team use automation testing, and the automation test must read the value on the input field. for example:
                                  If user enters zero (0) then get zero (0) value
                                  If user enters minus(-) then get minus(-) value not (-0) value

                                  so I use format: #,##0.## to keep zero number and I want to remove the behaviour if user enter zero (0) the result not (-0) but keep (0)

                                  Thank

                                • Agus W 12.04.2019

                                   I want to remove the behaviour if the user enters zero (0) the result not (-0) but keep (0) ===> sorry I mean, I want to remove the behaviour if user enter minus (-) the result not (-0) but keep (-). thanks

                                • Alessandro (DevExpress Support) 12.05.2019

                                  Hi,

                                  There is no way to hide the 0 symbol if you specified it in the format string as I mentioned above. As a workaround, you can set the valueChangeEvent option to the "keyup" value and handle the onValueChanged event as illustrated in the modified sample: https://codepen.io/Alex969/pen/PowweBN.

                                • Agus W 12.05.2019

                                  OK, thank a lot Alessandro. I'll try

                                • Alessandro (DevExpress Support) 12.05.2019

                                  You are welcome!