我有一个多步形式。我有ng-show取决于输入[type =" text"]是否为空。
现在,它适用于表单的一个部分,但不适用于表单的其他部分。
<div id="wrapper-signup">
<h1>Borrower Signup</h1>
<p>Register and start borrowing money online.</p>
<div class="element-wrap">
<label>NAME<br>
<div class="name-wrap">
<input type="text" ng-model="newuser.firstname" name="firstname" id="firstname" value="" placeholder="First Name">
<input type="text" ng-model="newuser.lastname" name="lastname" id="lastname" value="" placeholder="Last Name">
</div>
<p class="error" style="width: 45%; color: red; font-size: 0.9em; clear: both; margin-bottom: 0; padding-bottom: 0;" ng-show="signForm.firstname.$dirty && newuser.firstname.length === 0">Firstname required</p>
<p class="error" style="width: 45%; color: red; font-size: 0.9em; clear: both; margin-bottom: 0; padding-bottom: 0;" ng-show="signForm.lastname.$dirty && newuser.lastname.length === 0">Lastname required</p>
</label><br>
</div>
<div class="element-wrap">
<label for="email">EMAIL
<div class="email-num-wrap">
<span class="awesome-icon"><i class="fa fa-envelope-o fa-lg email-icon" aria-hidden="true"></i></span><input type="email" id="email" ng-model="newuser.email" name="email" value="" placeholder="Email ID" required>
</div>
<p class="error" style="color: red; font-size: 0.9em;" ng-show="signForm.email.$invalid && signForm.email.$dirty">Enter a valid email</p>
</label>
</div>
<div class="element-wrap">
<label>MOBILE NUMBER
<div class="email-num-wrap">
<span class="awesome-icon"><i class="fa fa-mobile fa-lg mobile-icon" aria-hidden="true"></i></span><input type="number" id="number" ng-model="newuser.number" name="mobile" ng-minlength="10" ng-maxlength ="10" value="" placeholder="Enter 10 digit number" required>
</div>
<p class="error" style="color: red; font-size: 1em;" ng-show="signForm.mobile.$dirty && (signForm.mobile.$error.minlength || singForm.mobile.$error.maxlength)">Please enter a 10 digit number</p>
</label>
</div>
<div class="clear">
</div>
<div class="checkbox-wrap">
<input type="checkbox" class="checkbox" name="terms" value="" ng-model="tcheck" required><p class="checkbox-text">I have read and agree to the <a href="#">Privacy Policy</a>, <a href="#">Terms of Use</a> and consent to Electronic Disclosures.</p>
</div>
<div class="checkbox-wrap">
<input type="checkbox" class="checkbox" name="condiiton" value="" ng-model="ccheck" required><p class="checkbox-text">I authorize RupaiyaExchange to share my details with other Financial Institutions for credit card check and faster processing of loan.</p>
</div>
<a ui-sref='index.otp' ng-show="signForm.email.$valid && tcheck && ccheck && signForm.mobile.$valid && newuser.firstname.length !== 0 && newuser.lastname.length !== 0 " class="submit-signup">SIGNUP</a>
</div>
适用于上述视图,但不适用于以下视图
<div id="wrapper-identity">
<p>Please enter the following details</p>
<div class="aadhar-wrap">
<label for="aadhar">Aadhar Card</label><br>
<input type="text" name="aadhar" ng-model="newuser.aadhar" id="aadharN" value="" placeholder="Enter Aadhar Card No" required>
<p class="error" style="color: red; font-size: 0.9em; clear: both; margin-bottom: 0; padding-bottom: 0;" ng-show="signForm.aadhar.$dirty && newuser.aadhar.length === 0">Aadhar number required</p>
</div>
<div class="pan-wrap">
<label for="pan">PAN</label><br>
<input type="text" name="pan" ng-model="newuser.pan" value="" id="panN" placeholder="Enter PAN No" required>
<p class="error" style="color: red; font-size: 0.9em; clear: both; margin-bottom: 0; padding-bottom: 0;" ng-show="signForm.pan.$dirty && newuser.pan.length === 0">PAN number required</p>
</div>
<input type="submit" ng-hide="signForm.aadhar.$dirty && newuser.pan.length === 0 && signForm.pan.$dirty && newuser.aadhar.length === 0" ng-click="go('/index/done')" name="submit-info" value="Submit" id="submit">
</div>
我不想填充此地点,因为css文件非常大。
答案 0 :(得分:1)
尝试调查每种情况下每种情况返回的值。
例如,尝试在您的部分中使用它:
<p>
DEBUG: {{ signForm.aadhar.$dirty }} && {{ newuser.pan.length === 0 }} && {{ signForm.pan.$dirty }} && {{ newuser.aadhar.length === 0 }}
</p>
答案 1 :(得分:1)
不检查长度而是检查值newuser.pan
<p class="error" style="color: red; font-size: 0.9em; clear: both; margin-bottom: 0; padding-bottom: 0;" ng-show="signForm.aadhar.$dirty && !newuser.aadhar">Aadhar number required</p>
<p class="error" style="color: red; font-size: 0.9em; clear: both; margin-bottom: 0; padding-bottom: 0;" ng-show="signForm.pan.$dirty && !newuser.pan">PAN number required</p>
答案 2 :(得分:0)
错误在于ng-hide表达式。您应该使用ng-show,同时反转长度控件:
<input type="submit" ng-show="signForm.aadhar.$dirty && newuser.pan.length != 0 && signForm.pan.$dirty && newuser.aadhar.length != 0" ng-click="go('/index/done')" name="submit-info" value="Submit" id="submit">
它控制两个输入是否都已更改,其中有一些值。如果条件成立,则会出现“提交”按钮,否则将隐藏。