socialforge/public/javascripts/wechat/directives/form_validate.js

25 lines
782 B
JavaScript
Raw Normal View History

2016-06-17 18:18:03 +08:00
app.directive('pwdconfirm', function(){
return {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl){
ctrl.$validators.pwdconfirm = function(modelValue, viewValue) {
return scope.user && scope.user.password == viewValue;
}
}
}
2016-08-10 16:08:30 +08:00
});
app.directive('unconfirm', function(){
return {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl){
ctrl.$validators.unconfirm = function(modelValue, viewValue) {
if(viewValue == ""){
return true;
}
// return (/^[a-zA-Z\d]\w{0,23}[a-zA-Z\d]{0,1}$/.test(viewValue));
return (/^[a-zA-Z][a-zA-Z\d]{3,14}$/.test(viewValue));
2016-08-10 16:08:30 +08:00
}
}
}
2016-06-17 18:18:03 +08:00
});