现在的位置: 首页 > 综合 > 正文

js正则表达式判断是否为实数

2013年02月21日 ⁄ 综合 ⁄ 共 456字 ⁄ 字号 评论关闭

正则表达式如下:

                        var e_shishu = oSheet.Cells(i, 7).Value;

                        if (!/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(e_shishu)) {
                            //輸入的資料不符合float數值格式 !
                            alert("excel格式錯誤【第" + i + "行實數應該為數字】!");
                            document.getElementById('MasterPage$MasterPageContent$exceldetail').value = "";
                            //關閉層
                            divClose();
                            oWB.Close();
                            oWB = null;
                            oXL = null;
                            return;
                        }

抱歉!评论已关闭.