Angular js表单验证

!!!!千万不要忘记了ng-app开启angular js和导入anjular js文件

<title>无标题文档</title>
</head>
<script src="angular-1.6.8/angular.js"></script>
<body ng-app="">

<form name="user">
	<h2>注册</h2>
    <input type="email" name="username" ng-model="username" required />
     <span ng-show="user.username.$error.required">输入的内容不能为空</span>
     <span ng-show="user.username.$error.email">输入的不符合邮件格式</span>
     <br />
     <input type="password" name="passwd" ng-model="passwd" required="required" ng-minlength="4" ng-maxlength="10"/>
      <span ng-show="user.passwd.$error.required">输入的内容不能为空</span>
      <span ng-show="user.passwd.$error.minlength">输入的内容小于4位</span>
      <span ng-show="user.passwd.$error.maxlength">输入的数字大于10位</span>
      <br />
     <input type="button" value="提交"/>
     
</form>

</body>


猜你喜欢

转载自blog.csdn.net/qq_39125684/article/details/79787182