<script>
function checkfloat(s){
var arr=s.match(/^\d+\.\d+$/);
return arr!=null
}
alert(checkfloat("1.11"));
alert(checkfloat("a.11"));
alert(checkfloat("1"));
</script>
function checkfloat(s){
var arr=s.match(/^\d+\.\d+$/);
return arr!=null
}
alert(checkfloat("1.11"));
alert(checkfloat("a.11"));
alert(checkfloat("1"));
</script>
<script>
function checkfloat(s){
return !isNaN(s)
}
alert(checkfloat("1.11"));
alert(checkfloat("a.11"));
alert(checkfloat("1"));
</script>
function checkfloat(s){
return /^\d+(\.\d+)?$/.test(s);
}
alert(checkfloat("1.11"));
alert(checkfloat("a.11"));
alert(checkfloat("1"));
</script>
还有<script>
function checkfloat(s){
return parseFloat(s).toString()==s;
}
alert(checkfloat("1.11"));
alert(checkfloat("a.11"));
alert(checkfloat("1"));
</script>