[转]ext注册验证,Ajax自动检测用户名是否存在
|
softfire
2008-08-08
上次论坛里好像有人问如何做动态验证的,一直没有时间去实现
今天下班后终于有时间搞定了! 演示地址:http://www.17ext.com/demo/ajaxregister/ 源码见附件,注意自己该以下ext库路径哦 var regform = new Ext.FormPanel({
monitorValid:true,
labelWidth:80,
baseCls: 'x-plain',
width:150,
defaultType:'textfield',
items:[{
fieldLabel:'用户名',
id:'txtUserName',
name:'username',
allowBlank:false,
blankText:'用户名不能为空!',
validator:CheckUserName,//指定验证器
invalidText:'用户名已经被注册!'
},{
inputType:'password',
fieldLabel:'密码',
name:'userpassword',
allowBlank:false,
blankText:'密码不能为空!'
},{
inputType:'password',
fieldLabel:'确认密码',
name:'cuserpassword',
allowBlank:false,
blankText:'确认密码不能为空!',
invalidText:'两次密码不一致!',
validator:function(){
if(Ext.get('userpassword').dom.value == Ext.get('cuserpassword').dom.value)
return true;
return false;
}
},{
fieldLabel: '电子邮件',
allowBlank:false,
blankText:'电子邮件不能为空',
regex:/^\d+$/, //正则表达式,这里没有详细写,只是验证了数字
regexText:'电子邮件格式错误!'
}],
buttons:[{
text:'注册',
type:'submit',
formBind:true,
handler:function(){
Ext.Msg.alert("恭喜","验证通过!!!!!");
}
},{
text:'清空',
handler:function(){regform.form.reset();}
}]
});
转自:http://www.17ext.com/showtopic-232.aspx |

