久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

html - form 表單 用戶名提示和錯誤提示分開顯示?

瀏覽:189日期:2024-03-16 14:50:19

問題描述

點擊輸入框,顯示用戶名提示,點擊立即注冊按鈕,在輸入框下顯示錯誤提示

<form name='checkForm' ng-init='isEmpty=false;'> <p class='form-group'><label class='col-sm-3 control-label'>用 戶 名</label><p class='col-sm-8 account'> <input type='text' placeholder='您的賬戶名和登錄名'ng-model='account'name='account'required='required'ng-pattern='regularList.account'ng-blur='checkForm.account.$blured = false;'ng-focus='checkForm.account.$blured = true;'autocomplete='off'/> <span ng-class='{’right’:(checkForm.account.$error.pattern),’error’:checkForm.account.$valid}'></span></p><span ng-messages='isEmpty && checkForm.account.$blured && checkForm.account.$error' role='alert'> <span ng-message='required' style='color: #ff0000'>用戶名不能為空</span></span><span ng-messages='checkForm.account.$blured && checkForm.account.$error' role='alert'> <span ng-message='pattern'style='color: #ff0000'>用戶名為4-20位中文數字與英文字母組成!</span></span> </p> <p ng-if='checkForm.account.$blured==true'><p ng-show='checkForm.account.$blured'> <i></i> <span>!支持中文、字母、數字、“-”“_”的組合,4-20個字符</span></p> </p>

具體效果如下

html - form 表單 用戶名提示和錯誤提示分開顯示?

現在是輸入內容不希望顯示錯誤提示我現在的問題是,輸入相應的內容,會有錯誤的提示,效果見下html - form 表單 用戶名提示和錯誤提示分開顯示?

目的:輸入內容不提示錯誤,點擊立即注冊,如果不符合相應的規范,再提示錯誤。求指點,謝謝

問題解答

回答1:

也是醉了。。。<input type='text' placeholder='您的賬戶名和登錄名'

ng-model='account' ng-pattern='regularList.account'/>

<span ng-show='showAccountError' role='alert'>

<span style='color: #ff0000'>用戶名為4-20位中文數字與英文字母組成!</span>

</span>當用戶提交的時候,在controller中用正則判斷$scope.account是否合法,不合法的話,就讓$scope.showAccountError=true.在頁面初始化的時候給這個變量賦false。

標簽: HTML
相關文章:
主站蜘蛛池模板: 玉山县| 原平市| 神木县| 大足县| 阳山县| 庆元县| 长泰县| 平阴县| 乐安县| 永川市| 定结县| 泗水县| 周宁县| 霍山县| 眉山市| 梨树县| 新巴尔虎右旗| 工布江达县| 高密市| 金乡县| 永善县| 土默特左旗| 科尔| 郎溪县| 鄯善县| 门源| 高台县| 思茅市| 犍为县| 榕江县| 襄垣县| 五大连池市| 密山市| 呼和浩特市| 衡阳县| 茂名市| 临安市| 松潘县| 丹江口市| 奉新县| 芜湖市|