Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMException: Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('number') does not support selection. #7

Open
KiaraGrouwstra opened this issue Oct 8, 2014 · 0 comments

Comments

@KiaraGrouwstra
Copy link

Chrome currently throws this error:
DOMException: Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('number') does not support selection.

I've worked around this by adjusting the script to the following, temporarily making the field type not 'number':

    $(this).keypress(function (event) {
        if (!event.charCode) return true;
        var elType = this.type;
        this.type = 'text';
        var part1 = this.value.substring(0,this.selectionStart);
        var part2 = this.value.substring(this.selectionEnd,this.value.length);
        this.type = elType;
        if (!mask.test(part1 + String.fromCharCode(event.charCode) + part2))
            return false;
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant