(9)ExtJS之Ext.form.field.Text

JS文件:

Ext.onReady(function(){
	Ext.QuickTips.init();
	var loginForm=new Ext.form.Panel({
		title:'Ext.form.field.Text示例',
		bodyStyle:'padding:5',//表单边距
		frame:true,
		height:120,
		width:200,
		renderTo:Ext.getBody(),
		defaultType:'textfield',//设置表单字段的默认类型
		defaults:{//统一设50置表单字段默认属性
			labelSeparator:':',//分隔符
			labelWidth:50,//标签宽度
			width:150,//字段宽度
			allowBlank:false,//是否允许为空
			labelAlign:'left',//标签对齐方式
			msgTarget:'side'//在字段的右边显示一个提示信息
		},
		items:[{
			fieldLabel:'用户名',
			name:'username',
			selectOnFocus:true,//得到焦点时自动选择文本
			//验证电子邮件格式的正则表达式
			regex:/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/,
			regexText:'格式错误'//验证错误之后的提示信息
		},{
		
			name:'password',
			fieldLabel:'密码',
			inputType:'password'//设置输入类型为password
			
		}],
		buttons:[{
		
		text:'登录',
		handler:function(){
			loginForm.form.setValues({userName:'user@com',password:'123456'});
		}
		}]
		
	});
});


JSP页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'JS1.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!-- extjs的样式文件 -->
	<link rel="stylesheet" type="text/css" href="js/extjs/resources/css/ext-all.css">
	<!-- extjs的核心文件 -->
	<script type="text/javascript" charset="utf-8" src="js/extjs/ext-all-debug.js"></script>
	<!-- 国际化文件 -->
	<script type="text/javascript" charset="utf-8" src="js/extjs/ext-lang-zh_CN.js"></script>
	
	<script type="text/javascript" charset="utf-8" src="base/009_text.js"></script>


  </head>
  
  
  <body style="margin:10px">
  	<div id="form"></div> 
  	<!-- 错误信息展示元素 -->
  	<div id="errorMsg"></div>
  </body>
</html>





你可能感兴趣的:(jsp,ExtJs)