[script language="javascript"]
function myCharKey(e) {
var e=window.event || e
var keyunicode=e.charCode || e.keyCode
//Allow alphabetical keys, plus BACKSPACE and SPACE
return (keyunicode>=65 && keyunicode<=122 || keyunicode==8 || keyunicode==32)? true : false
}
[/script]
[input type="text" name="myName" size="25" onkeypress="return myCharKey(event);" ]
Number only
var e=window.event || e;
var keyunicode=e.charCode || e.keyCode;
//Allow alphabetical keys, plus BACKSPACE and SPACE
//return (keyunicode>=48 && keyunicode<=57 || keyunicode==46)? true : false;
if((keyunicode>=48 && keyunicode<=57) || keyunicode==46 || keyunicode==8 || keyunicode==32){
var numIs = document.changeProfile.myName.value;
if((keyunicode>=48 && keyunicode<=57) || keyunicode==46){
numIs = numIs + String.fromCharCode(keyunicode);
}
alert(numIs);
return true;
}
else {
return false;
}
No comments:
Post a Comment