Flex登陆验证

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="this.tijiao.enabled=false;tijiao.label='数据要正确'" layout="absolute" backgroundColor="#ffffff" width="460" height="395" fontSize="12">
	<mx:Script>
		<![CDATA[
			import mx.effects.WipeLeft;
			import mx.validators.Validator;
			import mx.events.ValidationResultEvent;
			import mx.controls.ToolTip;
			import mx.managers.ToolTipManager;
			import mx.core.IToolTip;
			import mx.controls.Alert;
			
			private var user_nameBo:Boolean=false;
			private var user_telBo:Boolean=false;
			private var user_codeBo:Boolean=false;
			private var user_addressBo:Boolean=false;
			private var user_zipBo:Boolean=false;
			
			//验证执行的方法
			private function User_Focus(event:ValidationResultEvent,TextBo:Boolean):void{
			   
			    //验证错误执行
			     if(event.type==ValidationResultEvent.INVALID){
                      this.tijiao.enabled=false;
                 }else{//验证成功执行
                 
                    //并且是其他的都成功时,也就是在后一次验证,邮编成功时执行 
                    if(user_nameBo&&user_telBo&&user_codeBo&&user_addressBo&&user_zipBo){
			           this.tijiao.enabled=true;
			           this.tijiao.label="注册";
			         }
                 }
                     
			}
			//登陆方法
			private function User_login(event:MouseEvent):void{
			      Alert.show("fds");
			       if(this.user_pass.text==""){
			         Alert.show("密码不能为空!","错误消息");
			         return;
			     }else if(this.user_quePass.text!=user_pass.text){
			          Alert.show("两次密码不相同!","错误消息");
			         return;
  	              }
			}
			//重置按钮事件
			private function reset(event:MouseEvent):void{
			     this.user_name.text="";
			     this.user_pass.text="";
			     this.user_quePass.text="";
			     this.user_code.text="";
			     this.user_tel.text="";
			     this.user_address.text="";
			     this.user_zip.text="";
			}
		]]>
	</mx:Script>
	<mx:Style>
		.errorTip{fontSize:12px}
	</mx:Style>
	<!--验证姓名-->
	<mx:StringValidator id="nameValid" valid="User_Focus(event,user_nameBo=true)" invalid="User_Focus(event,user_nameBo=false)"  required="true" source="{this.user_name}" property="text" maxLength="20" minLength="2" tooLongError="姓名太长了!"
		 tooShortError="您的姓名低于我们的要求!" requiredFieldError="姓名不能为空!"/>
	<!--验证电话号码-->
	<mx:PhoneNumberValidator id="telValid" valid="User_Focus(event,user_telBo=true)" invalid="User_Focus(event,user_telBo=false)"  required="true" source="{this.user_tel}" property="text" requiredFieldError="不能为空!" invalidCharError="您输入的值包含特殊字符!"
		 wrongLengthError="输入的值不足10为数字!"/>
    <!--验证身份证号码-->
    <mx:StringValidator id="codeValid" valid="User_Focus(event,user_codeBo=true)" invalid="User_Focus(event,user_codeBo=false)" required="true" source="{this.user_code}" property="text" maxLength="18" minLength="18" tooLongError="您的身份证号码是假的!!"
		 tooShortError="您的身份证号码是假的!" requiredFieldError="身份证号码不能为空!"/>
    <!--验证地址-->
     <mx:StringValidator id="addressValid" valid="User_Focus(event,user_addressBo=true)" invalid="User_Focus(event,user_addressBo=false)" required="true" source="{this.user_address}" property="text" maxLength="20" minLength="2" tooLongError="您的地址是假的!!"
		 tooShortError="您的地址是假的!" requiredFieldError="地址不能为空!"/>
    <!--验证邮编-->
    <mx:NumberValidator id="zipValid" trigger="{this.user_zip}" triggerEvent="textInput" valid="User_Focus(event,user_zipBo=true)" invalid="User_Focus(event,user_zipBo=false)" required="true" source="{this.user_zip}" property="text" minValue="100000" maxValue="999999" domain="int" 
    	exceedsMaxError="邮编错误!" lowerThanMinError="邮编错误!" integerError="输入的值不是整数!" requiredFieldError="必须输入邮编!"/>
	
	
	<mx:Label text="用户名:" fontSize="12" x="71" y="44"/>
	<mx:Label text="密 码:" fontSize="12" x="79" y="76"/>
	<mx:Label text="密码确认:" fontSize="12" x="59" y="104"/>
	<mx:Label x="59" y="142" text="身份证号:" fontSize="12"/>
	<mx:Label x="71" y="170" text="电话号:" fontSize="12"/>
	<mx:Label x="83" y="198" text="地址:" fontSize="12"/>
	<mx:Label x="71" y="238" text="邮编号:" fontSize="12"/>
	<mx:TextInput  x="142" y="42" id="user_name"/>
	<mx:TextInput  displayAsPassword="true" id="user_pass" x="142" y="74" />
	<mx:TextInput  displayAsPassword="true" id="user_quePass" x="142" y="106"/>
	<mx:TextInput  id="user_code" x="142" y="140"/>
	<mx:TextInput  id="user_tel" x="142" y="172"/>
	<mx:TextInput id="user_address" x="142" y="204"/>
	<mx:TextInput  x="142" y="238" id="user_zip"/>
	<mx:Button id="tijiao" label="提交" x="131" y="289" click="User_login(event)" />
	<mx:Button  label="重置" x="241" y="289" click="reset(event)"/>
	
</mx:Application>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值