<script language="JavaScript" type="text/javascript">
var str = '12345678901234567890';
var str1 = '1234567890R';
var str2 = '123456789R';
function foo(a) {
if (/^\d{20}$/.test(a) || a.length == 10 && /[A-z]/.test(a) && /\d/.test(a) && !a.replace(/[A-z0-9]/g, "")) return true;
return false
};
document.write(foo(str)+" "+foo(str1)+" "+foo(str2))
</script>