Javascript input number only or text/number only

<script type=”text/javascript”>
function numericonly(e){
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
//alert(‘Character was ‘ + character);
//alert(code);
//if (code == 8) return true;
var AllowRegex = /^[\b0-9.]$/;
if (AllowRegex.test(character)) return true;
return false;
}
function typetextandnumonly(e){
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
var AllowRegex = /^[a-zA-Z0-9]$/;
if (AllowRegex.test(character)) return true;
return false;
}

</script>

 

<input name=”password” type=”password” id=”password” size=”50″ maxlength=”50″ value=”” onkeypress=”return typetextandnumonly(event);” />

, ,