Meteor AccountsTemplates Materialize Validation


#1

Hey people ! I’ve a Problem with my registration validation. I use the AccountsTemplate package from materialize and want to have a specific validation for the username registration. I want to check if to username already exist. If it does the field turns red and should show the errStr, but it doesnt. It only turns red. Could someone tell me why the errStr is not shown up?

Thanks !

So I use this code example which I found:
AccountsTemplates.addField({ _id: 'username', type: 'text', displayName: 'username', required: true, func: function(value){ var self = this; Meteor.call("userExists", value, function(error, userExists){ if (error) { console.log(error.reason); } if (!userExists) self.setSuccess(); else self.setError(userExists); self.setValidating(false); return errStr }); }, errStr: 'username already exist', minLength: 3 });

Meteor.methods({ userExists: function(username){ return !!Meteor.users.findOne({username: username}); } });