1.验证ip地址
<input name="ip" class="mini-textbox" required emptyText="请输入ip地址" onvalidation="isIpAddress" />
// ip地址验证 function isIpAddress(e){ var reg = new RegExp("^(\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])$"); if (e.isValid) { if (reg.test(e.value)) { e.isValid = true; }else{ e.errorText = "请输入正确的ip地址"; e.isValid = false; } } }