Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6391421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:40:09+00:00 2026-05-25T03:40:09+00:00

In the HTML5 INPUT type=’number’ the user can change the value by clicking on

  • 0

In the HTML5 INPUT type='number' the user can change the value by clicking on up/down arrows that are part of the INPUT box. The user might also click in the box for focus or for editing its contents.

Is there any easy way to distinguish between these two activities in the click trigger?


from @cvsguimaraes answer, which better demonstrates the theory.

using his methodology, here is my finished(?) version. the purpose: make sure regular change triggers are called when using +/- to change data.

// input/mouseup triggers to call change from +/- mouse clicks
// want to wait 500ms before calling change in case successive clicks
render.inputCh = false;
render.inputCt = 0;
render.inputFn  = function(e) {
    render.inputCh = true;
}
render.mouseupFn  = function(e) {
    if( render.inputCh ) {
        render.inputCh = false;
        render.inputCt++;
        setTimeout( next, 500 );
    }       
    function next() {
        render.inputCt--;
        if( render.inputCt ) return;
        var change = document.createEvent("Event");
        change.initEvent('change',true,true);
        e.target.dispatchEvent(change);
    }
}

// using input/mouseup triggers
document.getElementById('number').addListener('input',render.inputFn,true);
document.getElementById('number').addListener('mouseup',render.mouseuptFn,true);

// normal change trigger - will be called normally and via +/- mouse click
document.getElementById('number').addListener('change',changeFn,false);

on chrome it’s working flawlessly so far except that when you remove focus from the ITEM the change trigger will kick in again. I solved this by having a low level change trigger that stops propagation if the previous change call was from the mouseup.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:40:10+00:00Added an answer on May 25, 2026 at 3:40 am

    When the user change the value by clicking on up/down arrows the input event is triggered conveniently between mousedown and mouseup.

    const input = document.getElementById('age')
    const on = (ev, fn) => input.addEventListener(ev, fn)
    
    const status = document.getElementById('status')
    const write = (...txt) => status.innerText = txt.join()
    
    let lastEv = 'none';
    on('keydown', () => lastEv = 'keydown')
    on('mousedown', () => lastEv = 'mousedown')
    
    on('input', () => {
      if (lastEv === 'mousedown') write('changed from mouse', input.value);
      if (lastEv === 'keydown') write('changed from keyboard', input.value)
    });
    <input id="age" type="number" value=30> <br>
    <div id="status"></div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML input box <input type=text id=foo value=bar> I've attached a handler
Supposedly in HTML5 in Safari, you can define your input type as search and
In HTML5 there is a new input type, 'search'. On most browser it's just
How to change the color of content in HTML input type text while entering
I try to use html5 element, which is <input type='range' step='1' min='-300' max='-1' />
I have the below code in my .aspx page. <input type=hidden id=fbinfo name=fbinfo value=
I have an html select box and a search field (input type) When I
The jQuery validation plugin breaks for elements that have a HTML5 type defined. $(document).ready(function(){
I'm trying to use HTML5 to validate a number input. I am using jQuery
I was hoping to use HTML5's input control (with range type) to allow our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.