<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>validate.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css">
<script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../ext/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
// 非空验证,通过allowBlank:false实现
var name = new Ext.form.TextField(
{
name:"name",
fieldLabel:"用户名",
allowBlank:false,
blankText:"用户名不能为空!",
width:300,
renderTo:document.body
}
);
// 长度验证
var pwd = new Ext.form.TextField(
{
name:"pwd",
fieldLabel:"密码",
inputType:"password",
minLength:6,
maxLength:16,
minLengthText:"密码至少6位!",
maxLengthText:"密码最多16位!",
width:300,
renderTo:document.body,
allowBlank:false,
blankText:"密码不能为空!"
}
);
// vtype验证。可以验证包含以下:1.字母和下划线(alpha)。2.字母、数字、下划线(alphanum)。3.邮箱(email)。4.网址(url)
var url = new Ext.form.TextField(
{
name:"url",
fieldLabel:"网址",
allowBlank:false,
blankText:"网址为必输项!",
vtype:"url",
vtypeText:"您的网址输入有误!",
width:300,
renderTo:document.body
}
);
// 正则表达式验证
var file = new Ext.form.TextField(
{
name:"name",
fieldLabel:"Name",
width:300,
allowBlank:false,
blankText:"name字段不能为空!",
renderTo:document.body,
regex:/^w{8,}$/,//至少6个字符
invalidText:"请输入至少8这个字符!"
}
);
});
</script>
</head>
<body>
</body>
</html>
ext--表单验证
最新推荐文章于 2021-08-05 22:16:11 发布