私はイオン角度に取り組んでいます。User Profile
入力フィールドがFirst Name
、Last Name
、などCell Phone
であるページで検証を実行したい。Password
私が達成したいのは、最後のフィールドの下部に一度に 1 つのエラー メッセージを表示することです。使用するng-messages
と、フィールドごとに個別のメッセージが表示されますが、最初のエラーメッセージのみを表示したいです。
以下は私のhtmlコードです
<!-- input fields defined -->
<label class="item item-input item-stacked-label">
<span class="input-label">First Name</span>
<input type="text" placeholder="jack" name="fName" ng-model="userData.fName" required="required" ng-focus="clearValidation();" ng-class="{ 'errorCls' : profileInfoForm.fName.$invalid, 'noErrorCls' : profileInfoForm.fName.$valid}"/>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Last Name</span>
<input type="text" placeholder="dow" name="lName" ng-model="userData.lName" required="required" ng-focus="clearValidation();" ng-class="{ 'errorCls' : profileInfoForm.lName.$invalid, 'noErrorCls' : profileInfoForm.lName.$valid}"/>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Cell Phone Number</span>
<input type="text" placeholder="185-728-4380" name="cellPhone" ng-model="userData.cellPhone" required="required" />
</label>
<!-- input fields validations defined -->
<div ng-messages="(profileInfoForm.$submitted || profileInfoForm.fName.$dirty) && profileInfoForm.fName.$error">
<span ng-message="required">Please enter first name</span>
</div>
<div ng-messages="(profileInfoForm.$submitted || profileInfoForm.lName.$dirty) && profileInfoForm.lName.$error">
<span ng-message="required">Please enter last name</span>
</div>
<div ng-messages="(profileInfoForm.$submitted || profileInfoForm.cellPhone.$dirty) && profileInfoForm.cellPhone.$error">
<span ng-message="required">Please enter cellphone number</span>
</div>
どうすればいいですか?あなたの助けが必要です。
ありがとうございました。