Input/character validation on an input-element
Whatever you do DON'T MODIFY Object.prototype

Modifying Object.prototype is one of the worst things you can do in JavaScript

Quoting MDN:


  Warning: Changing the [[Prototype]] of an object is, by the nature of how modern JavaScript engines optimize property accesses, a very slow operation, in every    browser and JavaScript engine. The effects on performance of altering inheritance are subtle and far-flung, and are not limited to simply the time spent in obj.__proto__ = ... statement, but may extend to any code that has access to any object whose [[Prototype]] has been altered. If you care about performance you should avoid setting the [[Prototype]] of an object. Instead, create a new object with the desired [[Prototype]] using Object.create().




What should I do?

Preferably create a function:

function Validate(element, regex) {
    // code
}


but if you want to extend an element use Element.prototype, preferable with Object.defineProperty:

Object.defineProperty(Element.prototype, 'validate', {
    value: function(regex) {
        // code
    }
});


The bonus of using this is you can instead of getters and setters which are pretty cool too.

Avoid empty ifs

Here you have:

if (c.match(regex) || allowed.indexOf(e.which) &gt;= 0) {
    //Do nothing
} else {
    e.preventDefault();
}


instead, use a NOT (!):

if (!(c.match(regex) || allowed.indexOf(e.which) &gt;= 0))
    e.preventDefault();


the best way to write this specific condition would be:

if(!c.match(regex) || allowed.indexOf(e.which) &lt; 0)


Use clear variable names

As much as I love code-golf (writing short code), this is not it. Make sure your variable names are clear.

I don't know what the c variable does so I can't suggest an alternative name, this also makes it more confusing to me on the workings of your code.

Use Regex literals not strings

Your example shows:

"[0-9A-Fa-f]"


That's a string, not a Regex, use Regex literals (to avoid escaping also):

/[0-9A-Fa-f]/