I have a custom validation file using jQuery that I wrote myself. It is being used in a few pages on my site.
Now I need it on a part of my site that is an Angular app. I would like to include this file and it should work the same way. I cannot change the file to be a directive or other angular file because its being used on other parts of my site.
This validator works by adding classes to the inputs and the jquery watches those elements and validates after action occurs.
HTML:angularview.html
<input type="text" ng-model="vm.Email" name="email" class="required pattern" pattern_type="email" />
Javascript: formvalidation.js
$('.required, .pattern').on('blur', function () {
if ($(this).hasClass('required') && !$(this).val()) {
addError(this, 'required');
return;
}
if ($(this).hasClass('pattern') && !isValidInput($(this).attr('pattern-type'), $(this).val())) {
addError(this, 'invalid');
return;
}
});
Question:
How can I get this javascript file to run in my angular view?
EDIT:
I will try to be clearer.
This is not a jquery plugin. This is my own javascript file and it works using jquery. I watch inputs with a specific class name and on changes, I call functions on the page to validate(see example). How would I use this in a directive or is there a way that the functions in this file can be called by adding the correct classes to my inputs?