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

  • Home
  • SEARCH
  • 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 598931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:26:34+00:00 2026-05-13T16:26:34+00:00

On a recent project, I need have a hex mask (0x0 – 0xFF) as

  • 0

On a recent project, I need have a hex mask (0x0 – 0xFF) as one of the input fields on an HTML form. I know I could just use a regular input to get the hex value, and then I can validate it along with the other form submission validation.

However, for some of the other decimal fields I am using ui.spinner.js (github) to allow the user to hit the up/down buttons to toggle the value of the number. It would be nice to have a similar control for inputting hex values. Or at least, a control that is a bit “richer” than a simple input element.

Does anyone know if such a plugin exists?

Thanks in advance.

Update

I neglected to mention the spinner control that I am using. My apologies for the confusion.

  • 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-13T16:26:35+00:00Added an answer on May 13, 2026 at 4:26 pm

    Ended up solving this by writing custom format and parse handlers, as well as overriding the keypress event to enalble the user to type in hex digits:

            // Functions for dealing with hex values in spinners
            var parseHex = function(val) {
                        var options = this;
    
                        if (options.group == '.')
                            val = val.replace('.', '');
                        if (options.point != '.')
                            val = val.replace(options.point, '.');
                        return parseFloat(parseInt(val, 16));
                    },
                formatHex = function(num, places) {
                        var options = this,
                        regex = /(\d+)(\d{3})/,
                        result = ((isNaN(num) ? 0 : Math.abs(num)).toFixed(places)) + '';
    
                        for (result = result.replace('.', options.point); regex.test(result) && options.group; result=result.replace(regex, '$1'+options.group+'$2')) {};
                        return (num < 0 ? '-' : '') + options.prefix + parseInt(result).toString(16) + options.suffix;
                    },
                 keypressHex = function(e) {
                    var ch = String.fromCharCode(e.charCode || e.keyCode)
                    if (((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'f')))
                        return true;
                    return false;
                 };
    
            jQuery('#myinput')
                .spinner({
                    min: 0,
                    max: 255,
                    prefix: '0x',
                    format: formatHex,
                    parse: parseHex});
            jQuery('#myinput').unbind('keypress.uispinner'); // Explicitly remove the controls keypress validation
            jQuery('#myinput').bind('keypress.uispinner', keypressHex);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a recent project, I built my own MVC framework in PHP. One of
In a recent project I have nearly completed we used an architecture that as
On a recent project I have been working on in C#/ASP.NET I have some
For my recent project I need to work with as1. The problem is that
In a recent project I put a captcha test on a login form, in
For a recent project, I have a PHP script running as a CLI-based daemon.
Whilst working on a recent project, I was visited by a customer QA representitive,
In a recent project the lead developer designed a database schema where larger tables
There is another recent Project Euler question but I think this is a bit
On a recent Java project, we needed a free Java based real-time data plotting

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.