StratusForms icon indicating copy to clipboard operation
StratusForms copied to clipboard

function formatPhone tweak

Open rtonerii opened this issue 6 years ago • 0 comments

I was using the phone format and I found out that any time a user deleted a character it was causing issue.

I modified the function to take care of this.

It does not try to format if they hit the delete key or backspace.

function formatPhone(element) {
    var key = event.keyCode || event.charCode;
    if( key == 8 || key == 46 ){
        return false;
    }

    if (element.value.length == 3) {
        element.value += "-";
    } else if (element.value.length == 7) {
        element.value += "-";
    }
}

rtonerii avatar Feb 14 '19 19:02 rtonerii