利用javascript进行数字check
function checkNumber(str) {
var i;
var len = str.length;
var chkStr = "1234567890";
if (len == 1) {
if (chkStr.indexOf(str.charAt(i)) < 0) {
return false;
}
} else {
if ((chkStr.indexOf(str.charAt(0)) < 0)) {
return false;
}
for (i = 1; i < len; i++) {
if (chkStr.indexOf(str.charAt(i)) < 0) {
return false;
}
}
}
return true;
}
function checkNumber(str) {
var i;
var len = str.length;
var chkStr = "1234567890";
if (len == 1) {
if (chkStr.indexOf(str.charAt(i)) < 0) {
return false;
}
} else {
if ((chkStr.indexOf(str.charAt(0)) < 0)) {
return false;
}
for (i = 1; i < len; i++) {
if (chkStr.indexOf(str.charAt(i)) < 0) {
return false;
}
}
}
return true;
}
String temp;
int i;
try{
i=Integer.valueOf(strnumber).intValue();
System.out.print(i);
return true;
}
catch(Exception e){
System.out.print("is not a number") ;
return false;
} //String.valueOf(strnumber.charAt(i) ).toString().equals(String.valueOf(j).toString() ) ;
}
private boolean isDecimal(String strnumber){
String temp;
double i;
try{
i=Double.parseDouble(strnumber);
System.out.print(i);
return true;
}
catch(Exception e){
System.out.print("is not a decimal") ;
return false;
} //String.valueOf(strnumber.charAt(i) ).toString().equals(String.valueOf(j).toString() ) ;
}