国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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

瀏覽:169日期: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
相關文章:
主站蜘蛛池模板: 英吉沙县| 普兰店市| 调兵山市| 宝兴县| 道孚县| 西华县| 封开县| 长子县| 从化市| 乌兰察布市| 丰都县| 遵化市| 永清县| 池州市| 八宿县| 什邡市| 东源县| 桐城市| 河北区| 攀枝花市| 洛浦县| 蒙自县| 保德县| 玛多县| 钦州市| 蕉岭县| 灵武市| 紫金县| 西城区| 姜堰市| 郸城县| 海丰县| 湘潭县| 麻江县| 湘潭县| 杭锦旗| 唐山市| 鱼台县| 汝南县| 托克逊县| 儋州市|