First, I clicked register button without values, my custom directive showed right alert (using sweet alert).
Also there was no problem when I have done same action after filled first input.
But when I filled second input and removed first input,
form validating ignored that first input is whether empty or not.
Here's my fiddle.
and below is my directive.
.directive('validFocus', function () {
return {
required: 'ngModel',
restrict: 'A',
scope: {
invalidHTML: '&showSwal'
},
link: function (scope, element) {
element.on('submit', function () {
var firstInvalid = element[0].querySelector('.ng-invalid');
if (firstInvalid) {
scope.invalidHTML({html: firstInvalid});
}
});
}
};
})
Thank you in advance and fix my foolish please. :)
.
.
UPDATE
Maybe these pictures can make understanding my purpose easy.
1. Click register button after filled first input
2. Click rigster button after removed first input value and filled second input

.
.
What I expected was 'Enter Name.' not 'Enter Blood Type.' in second picture.