I have the following code:
$('.pure').on('keyup', function (e) {
e.preventDefault();
var str = $(this).val();
$(this).val(str.replace(/[^a-z0-9\s,.-^%]+$/ig, ''));
});
I want to only allow for the following characters:
A-Z a-z 0-9 , . - % and space.
My string that I am entering in the input box:
You have selected the following date - %date%.
Results:
The % keeps being removed from the string. Other special characters are also being removed $& etc. Which is correct. But I do not want the % to be removed.