首页 > JS执行的一个奇怪问题

JS执行的一个奇怪问题

以下代码理论上来说在任何时候都不能成功提交的,因为所有的return值都被设为了false,但是现在出现了一个奇怪的现象:当IP验证成功的时候表单可以成功提交。

自己调试了以下,发现当IP验证成功时,程序执行完 for..in 循环就终止了,没有再继续往下执行

// 表单提交验证
$('#form_ipAclConfig').submit(function(){
	var ipRangeType = $.trim($('#ipRangeType').val());
	
	if (ipRangeType == '')
	{
		alert('请选择IP范围');
		return false;
	}
	
	if (ipRangeType == 2)
	{
		var customIpList = $.trim($('#customIpList').val());
		if (customIpList != '')
		{
			var customIpList = customIpList.split(";");
			var key;
			for (key in customIpList)
			{
				var ipRegexp = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
				customIpList[key] = $.trim(customIpList[key]);
				if (!ipRegexp.test(customIpList[key]))
				{
					alert('ip格式有误 -- '+customIpList[key]);
					return false;
				}
			}
		}
		else
		{
			alert('请填写自定义IP信息!');
			return false;
		}
	}
	
	return false;
});
【热门文章】
【热门文章】