js正則表達式判斷是否為實數

正則表達式如下:
                        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 = "";
                            //關閉層
                            pClose();
                            oWB.Close();
                            oWB = null;
                            oXL = null;
                            return;
                        }

摘自:先知的程序

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *