如何隐藏html5验证弹出消息

时间:2016-02-15 06:17:10

标签: angularjs html5 angularjs-directive

这里我为简单的表单创建了验证,我的要求是我不想要html5弹出消息,但我需要专注于特定的有效字段,该怎么办? 感谢您提前帮助............................................

'use strict';
var app = angular.module('telstraApp', []);
   
 
 
    

app.directive('accessibleForm', function () {
    return {
        restrict: 'A',
        link: function (scope, elem) {

            // set up event handler on the form element
            elem.on('submit', function () {

                // find the first invalid element
                var firstInvalid = elem[0].querySelector('.ng-invalid');

                // if we find one, set focus
                if (firstInvalid) {
                    firstInvalid.focus();
                }
            });
        }
    };
});
 
  
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>TelsApp</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!--<link data-require="bootstrap@*" data-semver="3.3.5" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />-->
    
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> 
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.13.2/select.min.css">


    <script data-require="angular.js@~1.3.15" data-semver="1.3.15" src="https://code.angularjs.org/1.3.15/angular.js"></script> 
  
     
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-rc.0/angular-sanitize.js"></script>    
</head>



<body class="hold-transition skin-blue sidebar-mini" data-ng-app="telstraApp">
    <div class="wrapper">
    
    <div class="row" style="   position: relative;   top: 0; height: 55px !important;z-index:9999;">
        
    </div>
        <!--<div id="header" ng-include="'layout/header/header.html'"  ></div> -->
         
        <!-- Left side column. contains the logo and sidebar -->
      
        <aside class="main-sidebar" style="  height: 100%;  top: 10px;   height:0px;  padding-top: 60px;">
          
           
        </aside>

        <div class="content-wrapper" style=" margin-top: -29px; margin-bottom: 10px; height: 350px;   overflow-y: auto; ">
            <!-- Main content -->
            <form>
           <input type="text" ng-required="true">
            <input type="text" ng-required="false">
             <input type="text" ng-required="true">
           
           
           <input type="submit">
           </form>
            <!-- /.content -->
        </div>
    </div>
    <!-- /.content-wrapper -->
    <!-- /.Footer -->
     
    <!-- /.Footer -->
    <script data-require="jquery@1.11.0" data-semver="1.11.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
     
    
   
   

</body>
</html> 

<style>
.appBanner{
    position:fixed; left:0; top: 0px; width: 1440px; border:2px; background-color:#6185BA;height: 46px;color: #000; font-family: 'Helvetica Neue', Arial, sans-serif;font-size: 12px;
}
</style>

1 个答案:

答案 0 :(得分:-1)

为了隐藏html5验证邮件,您必须在表单上指定novalidate,如下所示:

<form name='xyz' novalidate>
  //your form
</form>

在此处详细了解:disable html5 validations

您必须在要进行焦点的输入上指定autofocus。 看看这个小提琴,重点是email输入。 focus with novolidate