Giter Site home page Giter Site logo

Comments (7)

brunowego avatar brunowego commented on May 20, 2024 2

My solution for hex color:

$('.hexcolor').mask('SAAAAAA', {
    'translation': {
        S: {
            pattern: /[#]/
        },
        A: {
            pattern: /[A-Fa-f0-9]/
        }
    }
});

from jquery-mask-plugin.

igorescobar avatar igorescobar commented on May 20, 2024 1

Hi @hoeni
Assuming that is an specific use case, I don't see why I should implement that kind of implementation on a "generic" manner, that would increase the plugin's source code on a very significant way and the value in return would be very small. Although, you can implement this behaviour for your users using callbacks that jquery mask offers.

Example:

$('.date').mask('AA:AA:AA:AA:AA:AA', {
        onKeyPress: function(str, e, obj){ 
            $(obj).val(str.toLowerCase());
        }
   }
);

Hope it helps.

from jquery-mask-plugin.

igorescobar avatar igorescobar commented on May 20, 2024

You can do it:
$('.date').mask('FF:FF:FF:FF:FF:FF', {translation: {"F":"[0-9a-z]"}});

from jquery-mask-plugin.

hoeni avatar hoeni commented on May 20, 2024

Hi Igor,

Thanks for your quick reply!

That's what I'm doing at the moment and normalizing the input on the server side afterwards. It would be a great enhancement for the user experience though, if the input of the user is normalized while he types:

Say, I want to see capital letters for my hex, and the user types 0a:0F, it should be normalized to "0A:0F" (or "0a:0f", if I want to see small caps)

Asides from using two special mask characters like f and F there could be at least a generic alternative like having an additional option e.g.

$('.date').mask('FF:FF:FF:FF:FF:FF', {
    translation: {"F":"[0-9a-z]"},
    conversion: {"ABCDEF" => "abcdef"}
});

or similar configuration.

Tobi

from jquery-mask-plugin.

hoeni avatar hoeni commented on May 20, 2024

Hi,

that works like a charm! I wasn't aware of the keypress callback!
Thank you so much!

Tobi

from jquery-mask-plugin.

igorescobar avatar igorescobar commented on May 20, 2024

No problem! Enjoy ;)

from jquery-mask-plugin.

igorescobar avatar igorescobar commented on May 20, 2024

👍

from jquery-mask-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.