Javascript 角JS中的多个必填字段
我有一个新的个人资料表,有多个必填字段,电子邮件,密码和确认密码。如果表单处于无效状态,则“提交”按钮设置为禁用。我认为表单应该保持无效状态,直到用户填写完所有必需的字段。令我惊讶的是,angular只检查了我的第一个字段。如果它单独处于有效状态,则无论其他字段的状态如何,提交按钮都会被激活。我使用的是angular 1.0.7。这种行为背后的原因是什么Javascript 角JS中的多个必填字段,javascript,forms,angularjs,Javascript,Forms,Angularjs,我有一个新的个人资料表,有多个必填字段,电子邮件,密码和确认密码。如果表单处于无效状态,则“提交”按钮设置为禁用。我认为表单应该保持无效状态,直到用户填写完所有必需的字段。令我惊讶的是,angular只检查了我的第一个字段。如果它单独处于有效状态,则无论其他字段的状态如何,提交按钮都会被激活。我使用的是angular 1.0.7。这种行为背后的原因是什么 <form name='newProfileForm' ng-submit="formSubmit(newProfileForm.$va
<form name='newProfileForm' ng-submit="formSubmit(newProfileForm.$valid)" novalidate>
<fieldset>
<legend>Login Information</legend>
</fieldset>
<!-- NAME -->
<div class="form-group">
<label>Email</label>
<input type="email" name="email" class="form-control" ng-model="user.mail" required>
<p ng-show="newProfileForm.email.$invalid && newProfileForm.email.$dirty">Please enter valid email.</p>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="pass" required/>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input type="password" class="form-control" required/>
</div>
<fieldset>
<legend>Personal Details</legend>
</fieldset>
<div class="form-group">
<label>Title</label>
<select class="span3">
</select>
</div>
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control"/>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control"/>
</div>
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control"/>
</div>
<div class="form-group">
<label>Date of Birth</label>
<input type="text" class="form-control"/>
</div>
<div class="form-group">
<label>Address</label>
<textarea rows="3"></textarea>
</div>
<div class="form-group">
<label>Country</label>
<select class="span3">
</select>
</div>
<div class="form-group">
<label>State</label>
<select class="span3">
</select>
</div>
<div class="form-group">
<label>City</label>
<select class="span3">
</select>
</div>
<div class="form-group">
<label>Pin Code</label>
<input type="text" class="form-control"/>
</div>
<div class="form-group">
<label>Gender</label>
<select class="span3">
<option label="Male" value="Male"/>
<option label="Female" value="Female"/>
</select>
</div>
<div class="form-group">
<label>Field of Interest</label>
<input type="text" class="form-control"/>
</div>
<!-- SUBMIT BUTTON -->
<button type="submit" class="btn btn-primary" ng-disabled="newProfileForm.$invalid">Submit</button>
</form>
登录信息
电子邮件
请输入有效的电子邮件
密码
确认密码
个人资料
标题
名字
姓
联系电话
出生日期
地址
国家
陈述
城市
Pin码
性别
兴趣领域
提交
您忘记为密码和确认密码字段提供ng型号。喜欢吗
<input type="password" class="form-control" name="pass" ng-model="pass" required/>
<input type="password" class="form-control" name="confirmpass" ng-model="confirmpass" required/>