I am using the RegEx ^[0-9]+$"
to allow only digits.
I want to allow hyphens -
& spaces also.
Can any one help me to modify the RegEx to a proper one?
I was using following JS code to achieve the same, but in this way if the user is copying & pasting the text then the key press is not getting accounted.
//Allowed characters are : 8 = Back space,
//9 = Horizontal tab, 27 = esc, 127 = Delete,
//13 = Enter digits = 48 to 57, 45 = hypen
$('#PostalCode').keypress(function (e) {
var key = (e.keyCode ? e.keyCode : e.which);
return (key == 8 || key == 9 || key == 127 || key == 27 || key == 13 || key == 45 || (key >= 48 && key <= 57));
});