我想要的是如果輸入文本框的值是格式與否(1-10數字連字符號碼)我爲一個模式匹配/^[\d]+([-][\d]+)?$/g but it allows only 0-9(single digits) i not taking 11-20(double digits)
我需要允許任何類型像10-11以及如何數字我可以做到這一點正則表達式不適用於jsp中的數字java
var txt = document.getElementById("txtShareCount").value;
if(txt.match(/^[\d]+([-][\d]+)?$/g)){
return true;
}
else if(!txt.match(/^[\d]+([-][\d]+)?$/g)){
alert("Pleae Enter Share count this(1-10) format");
document.getElementById("txtShareCount").focus();
return false;
}
else{return true;}
什麼是Java和JSP有什麼關係呢? – epascarello
所以加一個+來說一個或多個 – epascarello
我測試了你的代碼工作很好@Antony – JYoThI