正则表达式,,,,文本框中可以是小数.数字.其他的一律不行...

  function $(o) { return document.getElementById(o) }
            $('test').onblur = function() {
                debugger;
                var re = /^\d+(\.\d)?$/;
                var bol = re.test(this.value);
                if (bol == true) {

                }
                else {
                        alert("123");
                }

            }

 

 

 

他是空也是flase...直接弹出123...能不能在他是数字和小数和空的情况下是true.....谢谢了


qq_花开花谢_0
浏览 703回答 2
2回答

慕姐8265434

function $(o) { return document.getElementById(o) } $('test').onblur = function() {    debugger;    var re = /^\d+(\.\d)?$/;    var bol = re.test(this.value);    if (bol == true) {     }    else if(this.value !== ""){             alert("123");     } }加了一个为空的判断
打开App,查看更多内容
随时随地看视频慕课网APP