This article is mainly through the source code example and everyone to share AngularJS in the form of validation related knowledge, hope that through the sharing of this article, we learn AngularJS Helpful.
1. regular form verification;
the form validation instance provided in 2.AngularJs.
Instance Code
<!doctype html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>
LESSON 8
</title>
<link rel= "stylesheet" type= "Text/css" href= "Css/main.css"/>
<style>
#content1 {padding:16px;}
</style>
<body>
<form name= "MyForm" ng-submit= "Postform ()" >
<ul>
<li>
<label> Username:</label><input type= "text" name= "UserName" ng-model= "UserName" ng-pattern= " /^\w{8,18}$/"/>
<span style= "color:red" ng-show= "myform.username. $dirty && myform.username. $invalid" >
<span> Please enter A user name of 8 to six digits </span>
</span>
</li>
<li>
<label> Ref. </label><input type= "text" name= "Userindex" ng-model= "Userindex" ng-pattern= " /^\d+$/"/>
<span style= "color:red;" ng-show= "Myform.userindex. $dirty && myform.userindex. $invalid" >
Please enter your numeric number
</span>
</li>
<li>
<input ng-disabled= "MyForm. $invalid" type= "Submit" value= " submission "/>
</li>
</ul>
</form>
<script src= "Scripts/angular-1.4.6.min.js" ></script>
<script>
var app = Angular.module ("Lesson", []);
App.controller ("Formctrl", function ($scope) {
$scope. myform={};
$scope. UserName = ' Tom ';
$scope. Postform=function () {
Console.log ($scope. myForm);
}
});
</script>
</body>
Execution Result:
original link:http://www.maiziedu.com/wiki/angularjs/prove/
ANGULARJS form Verification Implementation method detailed