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

25 lines
782 B
JavaScript

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;
}
}
}
});
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));
}
}
}
});