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

Check on paste #4

Open
ghost opened this issue Jun 7, 2012 · 0 comments
Open

Check on paste #4

ghost opened this issue Jun 7, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 7, 2012

I've noticed there is no check on pasting code which would be handy.

So I've added this piece of code below the keypress function:

    // On paste we have to validate against the mask as well.        
    $(this).bind('paste', function(e) {
        var part1 = this.value.substring(0,this.selectionStart);
        var part2 = this.value.substring(this.selectionEnd,this.value.length);
        if (!mask.test(part1 + String.fromCharCode(event.charCode) + part2))
            $(this).val('');                

    }); 
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

0 participants