【发布时间】:2014-12-30 07:56:17
【问题描述】:
我试图验证我的用户输入,它的工作原理是用户可以按下提交 btn,它会错误地输入缺少的输入字段,以便用户知道他缺少什么输入。
我的问题是它只有在我删除action="/buy" method="post" 时才有效,但我需要它在没有错误时正常提交表单。
我该怎么做?
我使用这个表单验证和 angularjs validate http://www.brentmckendrick.com/code/xtform/
<form name="userForm" ng-submit="submitForm(userForm.$valid)" xt-form novalidate>
<div class="col-sm-6" ng-class="{ 'has-error' : userForm.fornavn.$invalid && !userForm.fornavn.$pristine }">
<label class="control-label" for="textinput">Fornavn <span class="star-color">*</span></label>
<input autocomplete="off" type="text" value="<?php echo set_value('fornavn'); ?>" name="fornavn" ng-model="fornavn" class="form-control" xt-validate required>
</div>
<button id="membership-box__payBtn" type="submit" name="betaling" class="btn btn-success text-uppercase">Go to payment</button>
</form>
【问题讨论】:
-
我不明白。在使用 Angular 构建的单页应用程序中,所有提交都是使用 AJAX 完成的。为什么要定期提交?
-
这是因为我在另一个需要提交的系统之上构建了 angularjs
标签: javascript angularjs forms