function isInteger(char) {
return (char.toString().search(/^-?[0-9]+$/) == 0 )
}
function validateQuan() {
var minExist = "false";
for (i=0; i<3; i++) {
var j = document.getElementById("ProductQuantity_"+i).value;
if (isInteger(j) && j > 0) {minExist = "true";alert("oi");}
}
if (minExist == "true") {$("#pvs_form").submit();} else {alert("Please enter at least one valid quantity");}
}
Above is my code, it s working on FF 3.6 and IE8, but not with IE7.
At IE7 "if (isInteger(j) && j > 0)
" couldn t lead to "true".
Even i remove "j > 0
" and use "[1-9]
" on regex.
任何更好的解决办法?
<><>>:> or,reg,任何编号<代码>> 9也属于“真实”。
edit : big sorry to all, i just found that the main problem actually because i got other form at the same page with the same id "ProductQuantity_
"+i, and likely it turn the IE7 to only look at the first element with that id found on page.
Maybe my original code was working actually, but thx to remind me that the regex is not as expected and to get better code. Thx and sorry once more.