easyui easyui-textbox自定义验证

$.extend($.fn.textbox.defaults.rules, {
    number : {
        validator : function(value, param) {
            return /^[0-9]*$/.test(value);
        },
        message : "请输入数字"
    },
    chinese : {
        validator : function(value, param) {
            var reg = /^[\u4e00-\u9fa5]+$/i;
            return reg.test(value);
        },
        message : "请输入中文"
    },
    checkLength: {
        validator: function(value, param){
            return param[0] >= get_length(value);
        },
        message: '请输入最大{0}位字符'
    },
    specialCharacter: {
        validator: function(value, param){
            var reg = new RegExp("[`~!@#$^&*()=|{}':;'\\[\\]<>~!@#¥……&*()——|{}【】‘;:”“'、?]");
            return !reg.test(value);
        },
        message: '不允许输入特殊字符'
    }    
    englishLowerCase  : {// 验证英语小写
        validator : function(value) {
            return /^[a-z]+$/.test(value);
        },
        message : '请输入小写字母'
    }
});


<div id="dlg" class="easyui-dialog" style=" width:400px; height:300px; padding:10px 20px;" data-options="resizable:true,modal:true"  closed="true" buttons="#dlg-buttons">
        <form id="fm" method="post" >
            <table>
                <tr>
                    <td class="normal" width="200px">登录名</td>
                    <td><input id="loginname_dlg"  name="loginname_dlg" class="easyui-textbox" required="true"  style="height:25px;" data-options="validType:['englishLowerCase','checkLength[50]']" >
                        <input  id="id_dlg"  name="id_dlg"  type="hidden">
                    </td>
                </tr>
                <tr>
                    <td class="normal" width="200px">用户名</td>
                    <td><input id="username_dlg"  name="username_dlg" class="easyui-textbox" required="true"  style="height:25px;" data-options="validType:['chinese','checkLength[50]']"></td>
                </tr>
                <tr>
                    <td class="normal" width="200px">联系电话</td>
                    <td><input id="phone_dlg"  name="phone_dlg" class="easyui-textbox"  style="height:25px;" data-options="validType:['number','length[11,11]']" ></td>
                </tr>
                
            </table>
        </form>
    </div>
    <div id="dlg-buttons">
        <a id="dlg-save"  href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" οnclick="save()">保存</a>
        <a id="dlg-close" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" οnclick="javascript:$('#dlg').dialog('close')">关闭</a>
    </div>



  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值