I would like to show validation messages on the form fields directly rather than using Bert if the username cannot be found or the password is incorrect. I have the following code, which works perfectly, but I would like to know if this the best/correct way or if I can use the jQuery validate plugin instead.
Meteor.loginWithPassword( email, password, ( error ) => {
if ( error ) {
if(error.reason === 'Incorrect password') {
$('input[name="password"]').attr('class', 'error');
$('<label class="error">' + error.reason + '</label>').appendTo('label[for="password"]');
}
if(error.reason === 'User not found') {
$('input[name="emailAddress"]').attr('class', 'error');
$('<label class="error">' + error.reason + '</label>').appendTo('label[for="emailAddress"]');
}
} else {
Bert.alert( 'Logged in!', 'success' );
}
});
Many thanks.