Reputation: 2175
Hi I am developing Website in angularjs and i am doing Registration page.I am trying to implement validation(Jquery plugin). I have imported required css and js files. Below is my html code.
<input class="form-control validate[required] text-input" type="text" name="LastName" placeholder="{{ 'Last Name' | translate }}" ng-model="Lname">
Below is my Registration controller.
(function () {
angular.module('RoslpApp').controller('MainRegistration', ['$rootScope', '$translatePartialLoader', '$translate', 'cfg', function ($rootScope, $translatePartialLoader, $translate, cfg) {
$translatePartialLoader.addPart('Registration');
$translate.refresh();
$translate.use('de_AR');
}]);
})();
To implement validation i want to write below code.
<script type="text/javascript">
jQuery(document).ready(function () {
// binds form submission and fields to the validation engine
jQuery("#formID").validationEngine();
$("formID").attr('autocomplete', 'off');
});
</script>
May I get some help where to write jquery code? Any help would be appreciated. Thank you.
Upvotes: 0
Views: 227
Reputation: 6629
You can write your jquery code like this in angularjs
// binds form submission and fields to the validation engine
angular.element(document.getElementById("formID")).validationEngine();
angular.element(document.getElementById("formID")).attr('autocomplete', 'off');
But that's really wrong way to implement validations, as angular have built in features to handle validations. please refer this link https://docs.angularjs.org/guide/forms
Upvotes: 1
Reputation: 2679
angular.element()
is the correct way to select the elements in angularjs.
But you can simply write the while code in your controller.
So just put the whole code from $(document).ready()
to your controller and it will work.
And as far as the form validation is concerned, you can use Angularjs Form Validation.
You can refer Angular Form Properties $valid, $invalid, $pristine, $dirty at the link below.
https://scotch.io/tutorials/angularjs-form-validation
Upvotes: 1