Q:

In Fire fox browser Backspace was not working when I use allow-pattern in angular js

I'm new in the front end. I'm using the allow-pattern directive for validation.In that backspace or arrow keys are not working when I open it on Mozilla firefox browser.Can anyone help me to fix this?
<input type="text" name="emergency_contact_name" allow-pattern="[a-z]"  ng-model="name" id="name" class="form-control parsley-success" value="name" data-parsley-id="0951">

A:

Your question does not clarify as to the allow-pattern implementation. The first hit I get on Google is this post on CodePen. Assuming that's what you're using, take a close look at this:
if (!keyCodeChar.match(new RegExp(attrs.allowOnlyPattern, "i"))) {
    return false;
}

This means that all other keys are rejected including backspace (8), delete (46), left-arrow (37), and right-arrow (39).
A simple (albeit not very pretty) fix is:
var controlKeyCodes = [8, 46, 37, 39];
if (!keyCodeChar.match(new RegExp(attrs.allowOnlyPattern, "i")) && controlKeyCodes.indexOf(keyCode) === -1) {
    return false;
}

