如果数字可以有正负,用这个
function isNumber(str){
var t=str.match(/^(-|\+|)[0-9]+/g);
return (t!=null)&&(t.length==1) && (t[0]==str);
}
如果数字可以是带小数点,用下边这个
function isNumber(str){
var t=str.match(/^(-|\+|)[0-9]+(\.|)[0-9]*/g);
return (t!=null)&&(t.length==1) && (t[0]==str);
}
是否字符
function isAlb(str){
var t=str.match(/^[A-Za-z]+/g);
return (t!=null)&&(t.length==1) && (t[0]==str);
}
判定是否為數字(直接加在TextBox 的屬性中)
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^-?\d|^\.]/g,''))"
onkeyup="value=value.replace(/[^-?\d|^\.]/g,'')"
function isNumber(str){
var t=str.match(/^(-|\+|)[0-9]+/g);
return (t!=null)&&(t.length==1) && (t[0]==str);
}
如果数字可以是带小数点,用下边这个
function isNumber(str){
var t=str.match(/^(-|\+|)[0-9]+(\.|)[0-9]*/g);
return (t!=null)&&(t.length==1) && (t[0]==str);
}
是否字符
function isAlb(str){
var t=str.match(/^[A-Za-z]+/g);
return (t!=null)&&(t.length==1) && (t[0]==str);
}
判定是否為數字(直接加在TextBox 的屬性中)
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^-?\d|^\.]/g,''))"
onkeyup="value=value.replace(/[^-?\d|^\.]/g,'')"