I have a text field where I need only 1
and 0
anything else will break my logic code.
How do i possibly restrict any other character from being entered in an input field?
I looked through posts regarding on a somewhat similar subject but they allowed numbers from 0-9 and so on.
I tried using the pattern
attribute in html but there is no pattern that does this, at least i haven't found it.
I have found this code:
$(function(){
$('#BinaryInputArea').bind('input', function(){
$(this).val(function(_, v){
return v.replace(/\s+/g, '');
});
});
});
which restricts SPACES
from being entered, this uses again patterns that only seem to be known by veterans. I tried adding [2-9]
in the .replace section but sadly it was out of the bounds of my logic.
EDIT: I am using a TextArea for input so a regular input pattern:[0-1]
wont work
`, right? Does your console show any errors?
– Scott Marcus Nov 05 '17 at 01:33