You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: angular-validation.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -398,15 +398,16 @@
398
398
* @param string message: error message to display
399
399
*/
400
400
varupdateErrorMsg=function(message,isFieldValid){
401
+
// Make sure that element has a name="" attribute else it will not work
402
+
if(typeofelm.attr('name')==="undefined"){
403
+
throw'Angular-Validation requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+elm.attr('ng-model')+'"';
404
+
}
405
+
401
406
// get the name attribute of current element, make sure to strip dirty characters, for example remove a <input name="options[]"/>, we need to strip the "[]"
throw'Angular-Validation requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+elm.attr('ng-model')+'"';
408
-
}
409
-
410
411
// find the element which we'll display the error message, this element might be defined by the user with 'validationErrorTo'
411
412
if(attrs.hasOwnProperty('validationErrorTo')){
412
413
// validationErrorTo can be used in 3 different ways: with '.' (element error className) or with/without '#' (element error id)
Copy file name to clipboardExpand all lines: readme.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,16 @@ For a smoother user experience, I also added validation on inactivity (timer). S
11
11
Now also supporting AngularJS 1.3.x
12
12
*current code should work with 1.2.x just the same*
13
13
14
-
## Requirements
15
-
Angular-Validation requires the element that will use validation to have a `name=""` attribute so that it can use this name to associate a `<span>` for error displaying. For example: `<input name="input1" ng-model="input1" validation="validator1" />`.
16
-
...* the necessity of name attribute is new since version 1.3.4+, since prior to this change it was asking the user to create his own `<span>` for error displaying.*
17
-
18
14
## Live Demo
19
15
[Plunker](http://plnkr.co/jADq7H)
20
16
<aname="live_demo"></a>
21
17
18
+
## Requirements
19
+
Angular-Validation requires the element that will use validation to have a `name=""` attribute, so that it can use this name to associate a `<span>` for error displaying. For example: `<input name="input1" ng-model="input1" validation="validator1" />`.
20
+
21
+
*the necessity of name attribute is new since version 1.3.4+, since prior to this change it was asking the user to create his own `<span>` for error displaying*
22
+
23
+
22
24
## Some Working Examples
23
25
Let's start with a simple example and then let's get down to real business.
*[1.3.2](https://github.com/ghiscoding/angular-validation/commit/41f9ed9abc7a6d66d4ecf6418b810459bf1d8717)`2015-01-03` Float number validator to also permit dot (.) as first character. Also removed keyboard blocking of invalid character on input type="number" now displays error message.
248
248
*[1.3.3](https://github.com/ghiscoding/angular-validation/commit/7b3043a97006a3d7043b198f89c91f8b6c49476e)`2015-01-04` Added changelog & updated Bootstrap(3.3.1), AngularJS(1.3.7) to latest versions
249
-
* 1.3.4 `2015-01-06` Removed the necessity of creating a `<span>` for displaying the error message, the directive now handles it by itself.
249
+
*[1.3.4](https://github.com/ghiscoding/angular-validation/commit/ba30d55ddb8bca44a8032fc8253356450bd4e1d4)`2015-01-06` Removed the necessity of creating a `<span>` for displaying the error message, the directive now handles it by itself.
250
+
*[1.3.5]()`2015-01-26` Throw an error message when user did not provide a `name=""` property inside the element to validate.
0 commit comments