var valid = (val.match(/^d+(?:.d+)?$/));
Matches:
1 : yes
1.2: yes
-1.2: no
+1.2: no
.2: no
1. : no
var valid = (val.match(/^-?d+(?:.d+)?$/));
Matches:
1 : yes
1.2: yes
-1.2: yes
+1.2: no
.2: no
1. : no
var valid = (val.match(/^[-+]?d+(?:.d+)?$/));
Matches:
1 : yes
1.2: yes
-1.2: yes
+1.2: yes
.2: no
1. : no
var valid = (val.match(/^[-+]?(?:d*.?d+$/));
Matches:
1 : yes
1.2: yes
-1.2: yes
+1.2: yes
.2: yes
1. : no
var valid = (val.match(/^[-+]?(?:d+.?d*|.d+)$/));
Matches:
1 : yes
1.2: yes
-1.2: yes
+1.2: yes
.2: yes
1. : yes
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…