jQWidgets Forums

jQuery UI Widgets Forums Editors DateTimeInput on change event and default value on user input

This topic contains 4 replies, has 2 voices, and was last updated by  Ivo Zhulev 8 years, 9 months ago.

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

  • nkanthed
    Participant

    Hi
    The onchange event is getting fired the moment user types in the first character in the date-time widget. The moment user type in the first character it defaults to todays date. Note that the format we have for the widget in ‘MM/dd/yyyy’.
    Is there any way to only fire the change event when the widget loses focus. If application contains custom logic on onchaange which needs to be initiated once user finishes typing in or the widget loses focus is there a solution for that.

    The examples you have in the demo causes on change to fire the moment user keys in the first key.


    Ivo Zhulev
    Participant

    Hi nkanthed,

    Take a look at the demo for the change event:
    http://jsfiddle.net/jqwidgets/M2cfD/
    The event fires the moment the widget looses focus.

    Best Regards,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/


    nkanthed
    Participant

    Hi

    I already looked at that demo. If you set the default value to null meaning the widget is blank then when the user enters the first character a change event is fired. Is there a way to only fire change event when widget loses focus.


    nkanthed
    Participant

    Hi Ivo

    Is there a way that the change is only fired when user tabs out of the field instead of the moment user tried to type in the first character.

    $(“#jqxDateTimeInput”).jqxDateTimeInput({
    width: ‘250px’,
    height: ’25px’,
    theme: ‘energyblue’,
    value : null
    });
    $(‘#jqxDateTimeInput’).on(‘change’, function (event) {
    alert(“Change has been made”);
    });

    In the example above you will see that the on change is fired twice.(try entering a date)

    Thanks
    Nitin K


    Ivo Zhulev
    Participant

    Hi nkanthed,

    The simplest way is to set a flag variable:

    let flag = true;
    ('#jqxDateTimeInput').on('change', (event) => {
        if(flag) {
          flag = false;
          return false;
        }
     // Your logic here    
    });

    Best Regards,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.