Skip to content

Check on paste #4

@ghost

Description

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('');                

    }); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions