I have a textbox which accepts 4 alphanumeric characters and spaces.
For ex: 34 56
should be valid
6789
is also valid.
$('#empIdtextbox1').on('blur', function () {
var val = $(this).val();
$(this).val(val.replace(" ", ''));
});
and
[MaxLength(4, ErrorMessage = "The emp code cannot be more than 4 alphanumeric characters")]
public string EmpId{ get; set; }
However when I type 34 56
, It replaces the spaces but displays The emp code cannot be more than 4 alphanumeric characters.
Any input on this will be helpful