如何禁用Angular required field msg?

时间:2016-12-04 00:19:42

标签: javascript html angularjs

我试图禁用此消息"请填写此字段。":

enter image description here

我想使用自己的自定义消息;我怀疑这是来自Angular,但似乎无法禁用它。我想过通过CSS禁用它,但不知道类或id。我试图检查元素'但是当我尝试时,这条消息消失了。

如果它有帮助,这是html表单。

<form name="personalForm" role="form" ng-submit="updatePersonal(updatePersonalForm)"
          ng-init="updatePersonalForm = {first_name: userFirstName,
            last_name: userLastName, job_title: userJobTitle, company_name: userCompanyName,
            location: userLocation, website: userWebsite}">

            <div class="auth-body">
              <div class="row" style="margin: 0;">
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <div class="form-group personal-form-group">
                    <label>first name</label>
                    <input type="text" name="first_name"
                    required class="form-control" ng-model="updatePersonalForm.first_name"
                    ng-class="{ 'error-input': personalForm.first_name.$invalid}">
                  </div>
                </div>
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <div class="form-group personal-form-group">
                    <label>last name</label>
                    <input type="text" name="last_name"
                    required class="form-control" ng-model="updatePersonalForm.last_name"
                    ng-class="{ 'error-input': personalForm.last_name.$invalid}">
                  </div>
                </div>
              </div>

              <div class="row" style="margin: 0;">
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <div class="form-group personal-form-group">
                    <label>job title</label>
                    <input type="text" name="job_title" ng-model="updatePersonalForm.job_title"
                     class="form-control">
                  </div>
                </div>
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <div class="form-group personal-form-group">
                    <label>location</label>
                    <input type="text" name="location" ng-model="updatePersonalForm.location"
                     class="form-control">
                  </div>
                </div>
              </div>

              <div class="row" style="margin: 0;">
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <div class="form-group personal-form-group">
                    <label>company name</label>
                    <input type="text" name="company_name" ng-model="updatePersonalForm.company_name"
                     class="form-control">
                  </div>
                </div>
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <div class="form-group personal-form-group">
                    <label>personal website</label>
                    <input type="text" name="personal_website" ng-model="updatePersonalForm.website"
                     class="form-control">
                  </div>
                </div>
              </div>

              <div class="row" style="margin: 0;">
                <div class="col-sm-6 account-input-container" style="padding: 0;">
                  <button type="submit" class="bubble-btn submit-btn pull-left" style="float: none !important;">update</button>
                </div>
              </div>
            </div>
          </form>

我能够打印出这些选项,但似乎无法找到所需信息的选项,也许它甚至不存在。

enter image description here

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

为表单标记添加novalidate。这将阻止默认的HTML5验证。

 <form action=" " novalidate>
     //form body
</form>