jQWidgets Forums

jQuery UI Widgets Forums Editors NumberInput allowNull and clearing value on keyup

This topic contains 5 replies, has 2 voices, and was last updated by  lqbweb 9 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • lqbweb
    Participant

    Hi,

    The normal behavior of the number input when the user selects the number and press Del is to reset the number to 0. Now, if I have allowNull option enabled, it makes sense to me to just clear it instead.

    I am trying to implement this behavior, and half succeeded by writing my custom on-keyup event that checks for that, but there is a short instance where the user can see the input box going to 0 before going clear. I guess this is happening because your callback gets called before. Is there anyway to change this?

    Thanks!


    lqbweb
    Participant

    also, it seems to be an issue related. When you specify a minimum value, and you select all text and press Del, it still goes to 0, leaving the field invalid.


    Hristo
    Participant

    Hello lqbweb,

    It’s difficult to figure out what exactly you’re trying to achieve and what purpose?
    If I understand you right – you try to clear the input when fired ‘keyup’ event.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    lqbweb
    Participant

    I have managed to do sort of what I was trying to do by overriding the ‘Delete’ function on the __proto__ of my number input instance, but I am afraid to be breaking some functionality.

    What I want to achieve is make your number input not to reset the value to “0” when trying to delete the content, but to null (since the field, accepts nulls due to allowNull). This makes perfectly sense in the real world, since some of my number fields may be optional, and I do not want to display anything at all, and leave the user the option to clear its content.


    Hristo
    Participant

    Hello lqbweb,

    Please take a look this example: http://jsfiddle.net/txhi/fp1zwg7k/

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    allowNull and clearing value on keyup #82030

    lqbweb
    Participant

    wow, that would have saved me a lot of time. thanks very much!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.