打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
jQuery EasyUI 的表单验证
<html><head><title></title>
<link style="text/css" rel="stylesheet" href="../参考资料/JQuery/jquery-easyui-1.1.2/themes/default/easyui.css">
<script src="jquery-1.4.2.min.js"></script>
<script src="jquery.easyui.min.js"></script>
<script>
$.extend($.fn.validatebox.defaults.rules, {
minLength: {
validator: function(value, param){
return value.length >= param[0];
},
message: '请输入至少(2)个字符.'
}
});
</script>
</head>
<body>
<form name="frmRegister" method="post">
<div style="width:500px;height:20px;">
name:<input name="txtName" class="easyui-validatebox" required="true" validType="minLength[3]" missingMessage="不能为空">
</div>
<div style="width:500px;height:20px;">
psw:<input name="txtPsw" type="password" required="true" class="easyui-validatebox" validType="minLength[2]" >
</div>
<div style="width:500px;height:20px;">
address:<input name="txtAddr" class="easyui-validatebox" required="true" validType="minLength[4]" invalidMessage="请输入至少4个字符">
</div>
<div style="width:500px;height:20px;">
email:<input name="txtEmail" validType="email" class="easyui-validatebox">
</div>
<div style="width:500px;height:20px;">
<input type="submit" value="注册">
</div>
</form>
</body>
</html>
方法
属性名类型描述默认值
required布尔定义文本域是否为必填项false
validType字符串定义字段的验证类型,比如email, url, etc.null
missingMessage字符串当文本框为空时提示的文本信息This field is required.
invalidMessage字符串当文本框内容不合法时提示的文本信息null
方法名
参数
描述
destroy
none
删除并且销毁组件
validate
none
做验证以确定文本框的内容是否是有效的。
isValid
none
调用验证方法并返回验证结果,true或者false
代码中的脚本是自定义验证规则,validType="minLength[4]" invalidMessage="请输入至少4个字符">它们同时存在,则提示语句会是“请输入至少4个字符”而不是script 里面的提示语句。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
easyui validatebox 验证类型
EasyUI 验证框使用方法
easyui validatebox 验证集合
easyUI 验证控件应用、自定义、扩展验证 手机号码或电话话码格式
EasyUI 教程
Jquery EasyUi实战教程布局篇
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服