<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>
解决方案 »
- JS新手求解答,为什么调用不了函数。。。
- 请问通过类方法的原型号方法扩充函数有什么不同?
- 页面边距离的确定,含滚动条?
- 超链接点击后链接本页 但显示超链接的文字改变
- 求一正则
- ajax获取xml文件报错问题
- 作为我来说是难题,大家帮我想想办法!高分相送
- 如何使图片中的热区有闪烁效果!
- 这是什么写法啊(x < color.length-1) ? x++ : x = 0;
- 一表单有一"Reset"按钮,当单击它时显示confirm对话框,点"确定",清除所填内容,单击"取消",不清除所填内容,该怎么做?
- JScript调用AcitveX对象问题
- 总结一下:什么状态下IE窗口中的鼠标同时显示为箭头与等待状态?
<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>