Skip to content

How to force an input to upper case .... #448

@Heirema

Description

@Heirema

Not really an issue, but an enhancement proposal.
Let say you set this as translation 👍

    $.jMaskGlobals = {
        translation: {
            '2': {pattern: /[A-Z]/, optional: true, uppercase : true},
            '3': {pattern: /[A-Z]/, uppercase : true},
            '4': {pattern: /[0-9]/, optional: true},
            '5': {pattern: /[0-9]/},
            '6': {pattern: /[A-Z0-9]/, uppercase : true},
            '7': {pattern: /[A-Z0-9]/, optional: true, uppercase : true},
        }
    };

Where a new pattern option is available : uppercase

This changement then in 'behaviour' :

                while (check()) {
                    var maskDigit = mask.charAt(m),
                        valDigit = value.charAt(v),
                        translation = jMask.translation[maskDigit];
                        if (translation) {
                             if (valDigit.match(translation.pattern) || (translation.uppercase &&  valDigit.toUpperCase().match(translation.pattern))) {
                                       if (translation.uppercase) {
                                              buf[addMethod](valDigit.toUpperCase());   
                                       } else {
                                              buf[addMethod](valDigit);
                                       }
                            if (translation.recursive) {
                                if (resetPos === -1) {
                                    resetPos = m;
                                } else if (m === lastMaskChar) {
                                    m = resetPos - offset;
                                }

                                if (lastMaskChar === resetPos) {
                                    m -= offset;
                                }
                            }
                            m += offset;
                      } else if ... etc

allow users to not care about cap lock status 😉
Very usefull for fast and "blind entry" ...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions