1.驗證ip地址ui
<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; } } }