<form name="rfqRespondForm">
价格一<input type="text" name="prod_price"><br>
价格一<input type="text" name="prod_price"><br>
价格一<input type="text" name="prod_price"><br>
<input type="button" value="check" οnclick="checkColor('color')">
检查一下时候是数字 1,000.00为合法
<script language="JavaScript">
//this function is to get off all the comma
function GetOutOffComma(str){
re = /,/gi;
newstr=str.replace(re, "");
return newstr;
}
//this function judge the regular expression if the current input is not obey the rule then we return false ,then focus and select it
function checkColor(object)
{
for(i=0;i<rfqRespondForm.prod_price.length;i++){
var pattern = /^(-?/d+)(/./d+)?$/;
//var obj = rfqRespondForm.prod_price[i].value ;
rfqRespondForm.prod_price[i].value = GetOutOffComma(rfqRespondForm.prod_price[i].value);
if(rfqRespondForm.prod_price[i].value.match(pattern)==null){
alert("产品的数量没有输入正确") ;
rfqRespondForm.prod_price[i].focus();
rfqRespondForm.prod_price[i].select();
return false;
}
else{
//alert("正确") ;
//alert(obj);
}
}
return true;
}
</script>