js判斷數(shù)字-正則表達(dá)式(轉(zhuǎn))
http://blog.sina.com.cn/s/blog_72b7a82d0100yfip.html
"^\\d+$" //非負(fù)整數(shù)(正整數(shù)
"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮點(diǎn)數(shù)
"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //負(fù)浮點(diǎn)數(shù)
測試:
<script>
function forcheck(ss){
type="^[0-9]*[1-9][0-9]*$";
var
RegExp(type);
if(ss.match(re)==null)
{
"請輸入大于零的整數(shù)!");
return;
}
</script>
|
|
posted on 2013-07-04 17:59 一堣而安 閱讀(228) 評論(0) 編輯 收藏 所屬分類: js_css