<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrapp{
margin: 30px;
}
.erro{
color:red;
}
.uerro{
border:1px solid red;
}
</style>
<link rel="stylesheet">
<script src="https://cdn.bootcss.com/angular.js/1.4.0-beta.4/angular-1.4.0-beta.5/angular.js"></script>
</head>
<body ng-app="">
<div class="wrapp">
<form name="signForm" ng-submit="formSubmit()">
<div>
<label>用戶名:</label>
<input name="username"
ng-model="un"
type="text"
required
ng-minlength="4"
ng-maxlength="12"
class="form-control"
>
</div>
<!-- <pre>{{ signForm.username }}</pre> -->
<label class="erro" ng-if="signForm.username.$invalid && signForm.username.$touched">
? 用戶名應該在4-12位之間
</label>
<div>
<label>密碼:</label>
<input name="password"
ng-model="pw"
type="password"
required
ng-minlength="4"
ng-maxlength="12"
class="form-control"
>
</div>
<pre>{{signForm.password}}</pre>
<label class="erro"
ng-if="signForm.password.$invalid && signForm.password.$touched">
密碼應該在4-12位之間
</label>
<div>
<input name="password2"
ng-model="pw2"
type="password2"
required
ng-minlength="4"
ng-maxlength="12"
class="form-control"
>
</div>
<pre>{{signForm.password2}}</pre>
<label class="erro" ng-if="signForm.password2.$modelValue==signForm.password2.modelValue&&signForm.password2.$touched">兩次輸入的密碼不一致
</label>
<div>
<button class="btn" type="submit">提交</button>
? ? ? ? </div>
</form>
</div>
</body>
</html>