HTML:
<input class = "remark" type = "text" maxlength = "500">
JS:
var $remarkInput = $('.remark');
$remarkInput.on('change',function(){
var regC = /[^ -~]+/g;
var str = $(this).val();
if (regC.test(str)){
var value = str.substr(0,500);
$(this).val(value);
}
});