javascript - AngularJS validating outside of a form -
i have more or less complex spa ~40 text input fields. input elements not bundled <form>, separated categories. if user submits, trigger validation function.
my first approach writing 2 directives, 1 string input , 1 numeric values, add attribute every invalid element, using validate() function every input field in order check whether or not has said attribute.
i stumbled on multiple issues, including fact jquery solution problem.
how accomplish in more convenient way?
one of ways have been handling form validation when things not inside of form using ng-pattern. ng-pattern can either direct regex there, or link expression run set of validations you.
it this.
<input type="text" ng-pattern="put regex here or expression"> the angular docs ng-pattern pretty sparse, luck.
this approach may not looking since evaluates 1 input @ time, hope helps.
Comments
Post a Comment