日期:2014-05-16  浏览次数:20352 次

Javascript 验证数字是否正确

?

function zk_validationNumber(tag,min,max) 
  {
	  if (checkRate(tag)) {
		alert("请输入数字");
		tag.focus();
		tag.select();
	  }
	  else if ($(tag).val() > max) {
			alert("数字越界");
			tag.focus();
			tag.select();
	  }
	  else if ($(tag).val() < min) {
			alert("数字太小");
			tag.focus();
			tag.select();
	  }
  }
function checkRate(input)
{
	 var re = /^[0-9]+?[0-9]*$/; 
	 if (!re.test(input.value))
	 {
		return true;
	 }
	 else {
		 return false;
	 }
}
?

?

?

?