-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
45 lines (40 loc) · 1.5 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<title>Angularjs Dynamic Form Validation Example</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<style>
.field-error{
color:red;
font-weight: bold;
}
</style>
</head>
<body ng-app="app">
<div class="content">
<div class="well">
<h3>Angularjs Dynamic Form Validation Example</h3>
<form name="form" ng-controller="FormController as myForm">
<div class="form-group col-md-12" ng-repeat="field in myForm.fields">
<span class="form-label">{{field.label}}</span>
<input type="{{field.type}}"
title="{{field.label}}"
ng-model="myForm[field.name]"
class="form-control"
validator-error-field="field.label"
validator-rules="field.rules"
validator-error="field.error"
validator-function="myForm.fieldIsInvalid"
/>
<ul class="field-error" ng-repeat="error in field.error">
<li>{{error}}</li>
</ul>
</div>
</form>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="example.js"></script>
<script src="validator.js"></script>
</body>
</html>