Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to prevent numericstepper from setting the value to the defined Maximum when a number greater than maximum is entered in by keyboard and user hits the "Enter" key.

Guest
Jul 05, 2014 Jul 05, 2014

I need to set the Maximum so that the use can use the mouse to change the value of numericstepper (and not go over a certain number), but at the same time I have to allow the user to enter their value by typing in the text field. When the user enters a number greater than the Maximum, I disable the "Ok" button of the dialog and show a red warning(error message). The issue is that the user can hit "Enter" and numeric stepper would set the value to the Maximum and the dialog box would close and the rest of code would run. I want the numericstepper not to change the value and keep showing the warning even if the user hits the "Enter".

Note: Setting maxChar does not help since my maximum is 1000, and user might enter 5555

I would appreciate the help.

TOPICS
ActionScript
256
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2014 Jul 06, 2014

store the previous valid stepper value

assign the max stepper value 1 greater than the real max you want to use (assuming integer values)

and use a change event to detect when the user changes your stepper.

if it's changed to a value greater than the real max, reset its value to the previous value.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 12, 2014 Jul 12, 2014

Thanks for trying to help, But

The issue is that if I set the maximum value of stepper 1 greater than the max value that I want, then the user can select an invalid value(of myMax + 1) when he clicks on the UP arrow of the numeric stepper(which is not acceptable for what I am working on).

I need to preserve the users invalid number, while not letting the user to select an invalid number by clicking UP key.

I noticed that when the user enters a number greater than the Maximum, and then click on the down arrow, it would set the value to 1 less than the maximum. This is not acceptable either.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2014 Jul 12, 2014

use the change event to detect if a user has incremented beyond your desired max and reset its value.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 18, 2014 Jul 18, 2014
LATEST

The issue with that solution is that when the user "Types" the number that is equal to  desiredMax + 1, it will reset the value to the desiredMax. As I mentioned earlier, I need to keep the invalid number and show a warning.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines