jQuery MiniUIの使用概要

1743 ワード

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;
            }
        }
    }