用正则匹配下面三种数据
1.IP地 址(多个用;号隔开)
比如 192.168.0.1 或者 192.168.0.1;192.168.0.2
2.远程端口(多个用,号隔开)
比如 3306 或者 3306,21,80
3.MAC地址(多个用,号隔开)
比如 0:a:eb:e6:6d:f7 或者 0:a:eb:e6:6d:f7,0:18:8b:18:13:7d
1./^((([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5])),)*(([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))+$/
2./^([1-9]+[0-9]+,)*[1-9]+[0-9]+$/
3./^(([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2},)*([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/
validator ip 地址验证:
$.validator.addMethod("ipChecks", function(value, element) {
var regexq=/^((([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]));)*(([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.((0)|([1-9][0-9]?)|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))+$/;
return this.optional(element) || (regexq.test(value));
}, $.validator.format("ip格式错误"));
<input class="form-control" type="text" name="equipmenInfo.ipaddress" ipChecks="true" placeholder="多个以;分割"/>