<form name="form1" ng-app=""> 帳號: <input type="text" name="account" ng-model="userAccount" ng-minlength="3" ng-maxlength="8" placeholder="帳號長度 3 ~ 8" autocomplete="off" required /><br /><br /> HTML5 密碼: <input type="text" name="pass" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,10}$" placeholder="至少一個大寫字母 + 一個小寫字母 + 一個數字,且長度 6 ~ 10" size="50" required /> <br /><br /> AngularJS 密碼: <input type="text" name="pass2" ng-model="pass2" ng-pattern="/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,10}$/" placeholder="至少一個大寫字母 + 一個小寫字母 + 一個數字,且長度 6 ~ 10" size="50" required /> <alert ng-class="{'error':form1.pass2.$error.pattern}"> 密碼不符合規範 </alert> <br /><br /> <input type="submit" value="send" ng-disabled="form1.$invalid" /> </form>
alert { display:none; } .error { display:block; color:red; }