검증 예제
검증 예제
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<h2>Validation Example</h2>
<form ng-app="myApp" ng-controller="validateCtrl"
name="myForm" novalidate>
<p>Username:<br>
<input type="text" name="user" ng-model="user" required>
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
<span ng-show="myForm.user.$error.required">Username is required.</span>
</span>
</p>
<p>Email:<br>
<input type="email" name="email" ng-model="email" required>
<span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
<span ng-show="myForm.email.$error.required">Email is required.</span>
<span ng-show="myForm.email.$error.email">Invalid email address.</span>
</span>
</p>
<p>
<input type="submit"
ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||
myForm.email.$dirty && myForm.email.$invalid">
</p>
</form>
<script>
var app = angular.module('myApp', []);
app.controller('validateCtrl', function($scope) {
$scope.user = 'John Doe';
$scope.email = 'john.doe@gmail.com';
});
</script>
</body>
</html>
HTML 양식 속성 인 novalidate 는 기본 브라우저 유효성 검증을 사용 불가능하게하는 데 사용됩니다.
예제 설명
AngularJS 지시어 ng-model 은 입력 요소를 모델에 바인딩합니다.
모델 객체에는 사용자 와 전자 메일 이라는 두 가지 속성이 있습니다.
ng-show 때문에 사용자 또는 전자 메일이 $ dirty 및 $ invalid 인 경우에만 color : red가 표시됩니다 .
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<h2>Validation Example</h2>
<form ng-app="myApp" ng-controller="validateCtrl"
name="myForm" novalidate>
<p>Username:<br>
<input type="text" name="user" ng-model="user" required>
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
<span ng-show="myForm.user.$error.required">Username is required.</span>
</span>
</p>
<p>Email:<br>
<input type="email" name="email" ng-model="email" required>
<span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
<span ng-show="myForm.email.$error.required">Email is required.</span>
<span ng-show="myForm.email.$error.email">Invalid email address.</span>
</span>
</p>
<p>
<input type="submit"
ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||
myForm.email.$dirty && myForm.email.$invalid">
</p>
</form>
<script>
var app = angular.module('myApp', []);
app.controller('validateCtrl', function($scope) {
$scope.user = 'John Doe';
$scope.email = 'john.doe@gmail.com';
});
</script>
</body>
</html>
HTML 양식 속성 인 novalidate 는 기본 브라우저 유효성 검증을 사용 불가능하게하는 데 사용됩니다.
예제 설명
AngularJS 지시어 ng-model 은 입력 요소를 모델에 바인딩합니다.
모델 객체에는 사용자 와 전자 메일 이라는 두 가지 속성이 있습니다.
ng-show 때문에 사용자 또는 전자 메일이 $ dirty 및 $ invalid 인 경우에만 color : red가 표시됩니다 .
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 208 | 부트스트랩 | 8년 전 | 2717 | ||
| 207 | AngularJS | 8년 전 | 1461 | ||
| 206 | AngularJS | 8년 전 | 1109 | ||
| 205 | AngularJS | 8년 전 | 984 | ||
| 204 | AngularJS | 8년 전 | 1385 | ||
| 203 | AngularJS | 8년 전 | 1182 | ||
| 202 | AngularJS | 8년 전 | 1499 | ||
| 201 | AngularJS | 8년 전 | 1448 | ||
| 200 | AngularJS | 8년 전 | 1418 | ||
| 199 | AngularJS | 8년 전 | 1344 | ||
| 198 | AngularJS | 8년 전 | 1225 | ||
| 197 | AngularJS | 8년 전 | 1388 | ||
| 196 | AngularJS | 8년 전 | 1043 | ||
| 195 | AngularJS | 8년 전 | 1251 | ||
| 194 | AngularJS | 8년 전 | 1267 | ||
| 193 | AngularJS | 8년 전 | 1613 | ||
| 192 | AngularJS | 8년 전 | 1359 | ||
| 191 | AngularJS | 8년 전 | 1581 | ||
| 190 | AngularJS | 8년 전 | 1548 | ||
| 189 | AngularJS | 8년 전 | 1640 | ||
| 188 | AngularJS | 8년 전 | 1395 | ||
| 187 | AngularJS | 8년 전 | 1366 | ||
| 186 | AngularJS | 8년 전 | 1399 | ||
| 185 | AngularJS | 8년 전 | 1433 | ||
| 184 | AngularJS | 8년 전 | 1476 | ||
| 183 | AngularJS | 8년 전 | 1467 | ||
| 182 | AngularJS | 8년 전 | 1007 | ||
| 181 | AngularJS | 8년 전 | 1385 | ||
| 180 | AngularJS | 8년 전 | 1276 | ||
| 179 | AngularJS | 8년 전 | 1247 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기