prova questa
function isValidStr(val) {
return /^[ A-Za-z0-9]{3,30}$/.test(val);
};
alert(isValidStr(' fff3R'));