(21)ExtJS之使用VType验证

本文详细探讨了ExtJS中如何利用VType进行表单验证,通过实例讲解了各种内置验证类型以及自定义验证规则的设置,帮助开发者提升表单数据的准确性和安全性。
摘要由CSDN通过智能技术生成

JS文件:

//6:表单中使用VType验证示例
Ext.onReady(function(){
	Ext.QuickTips.init();
	Ext.create('Ext.form.Panel',{
		title:'vtype示例',
		width:300,
		frame:true,
		renderTo:Ext.getBody(),
		bodyPadding:5,
		defaultType:'textfield',
		fieldDefaults:{
			labelSeparator:':',
			labelWidth:80,
			width:270,
			msgTarget:'side'
		},
		items:[{
			fieldLabel:'电子邮件',
			vtype:'email'
		},{
			fieldLabel:'网址',
			vtype:'url'
		},{
			fieldLabel:'字母',
			vtype:'alpha'
		},{
			fieldLabel:'字母和数字',
			vtype:'alphanum'
		}]
	});
	
});


JSP文件:

<%@ page
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
function showUserForm() { //将变量定义成局部变量,避免每次都生成一个新对象 var userForm = null; userForm = new Ext.FormPanel({ id:'conditionForm', labelWidth:'80', labelAlign:'right', border:false, bodyBorder:false, frame:true, items:[ layout:'column', items:[ { columnWidth:'.8', items:{ name:'userInfo.userId', hiddenName:'userInfo.userId', //hiddenName动态的绑定数据库中对应的字段 xtype:'textField', //xtype可以分为三类,textField为表单域的控件 fieldLabel:'用户编码*',//控件前的文本说明 labelSeparator:'', blankText : '填写用户编码', //为空的文本框提示信息 allowBlank:false, //不允许为空 maxLength:'50', //文本框允许输入的最大的长度,最小的minLength vtype:'specialChar', anchor:'80%' } },{ columnWidth:'.8', items:{ name:'userInfo.userName', hiddenName:'userInfo.userName', xtype:'textField', fieldLabel:'用户姓名*', labelSeparator:'', blankText:'填写用户姓名', allowBlank:false, maxLength:'100', vtype:'specialChar', anchor:'100%' } },{ columnWidth:'.8', items:{ name:'userInfo.pwd', hiddenName:'userInfo.pwd', xtype:'textField', inputType:'password', fieldLabel:'用户密码*', labelSeparator:'', blankText:'填写用户密码', allowBlank:false, maxLength:'12', minLength:'6', value:'123456', //用户默认的秘密 anchor:'100%' } },{ columnWidth:'.8', items:{ name:'rPwd', hiddenName:'rPwd', xtype:'textField', inputType:'password', fieldLabel:'确认密码*', labelSeparator:'', blankText:'二次输入的秘密要相同', allowBlank:false, vtype:'pwdRange', pwdRange:{begin:'userInfo.pwd',end:'rPwd'}, maxLength:'12', anchor:'100%' }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值