<SCRIPT type=text/javascript src="js/validator.js"></SCRIPT>
<SCRIPT type=text/javascript>
var a = validator({
"form": "validator-form",
ajaxSubmit:true,
beforSubmit:function(){
//alert("表单提交前执行的函数");
},
afterSubmit:function(){
alert("ajax提交后返回的数据是:"+this.responseText);
}
}).add({
"target": "username",
"rule_type": "username",
'action':'2.php',
'tips':'说点什么好呢'
}).add({
"target": "password",
"rule_type": "password"
}).add({
"target": "confirm-password",
"rule_type": "password",
"sameTo": "password",
'error':'你填写的密码不正确或者和原密码不同'
}).add({
"target": "age",
"rule_type": "number||empty",
"error":'虽然这玩意儿不是必填项,但既然你填了,就把它填对吧。'
}).add({
"target": "birthday",
"rule_type": "date||empty"
}).add({
"target": "id-card",
"rule_type": "idcard||empty"
}).add({
"target": "email",
"rule_type": "email"
}).add({
"target": "qq",
"rule_type": "qq||empty"
}).add({
"target": "telephone",
"rule_type": "phone||empty"
}).add({
"target": "mobile",
"rule_type": "mobile||empty"
}).add({
"target": "phone",
"rule_type": "phone||mobile",
"tips": "请输入您的手机或座机电话号码!"
}).add({
"target": "zip-code",
"rule_type": "zip||empty"
}).add({
"target": "ip-address",
"rule_type": "ip||empty"
}).add({
"target": "url",
"rule_type": "url||empty"
}).add({
"target": "message",
"rule_type": "require"
});
var reset = document.getElementById('reset');
var del = document.getElementById('del');
reset.onclick = function(){
a.reset();
}
del.onclick = function(){
a.remove('username');
}
</SCRIPT>
|