Home > Web Front-end > JS Tutorial > The use of regular expressions in angularJS

The use of regular expressions in angularJS

零到壹度
Release: 2018-04-21 14:57:29
Original
2899 people have browsed it

This article introduces the use of regular expressions in angularJS. It has a certain reference value. Now I share it with you. Friends in need can refer to it

<!DOCTYPE >
<html>
<head>
<meta charset="utf-8" />
<title>angular</title>
<script src="angular-1.5.8/angular.min.js"></script>
</head>
<body>
<form ng-app="myApp" ng-controller="validateCtrl" name="myForm" novalidate>
<p>用户名:<br>
<input type="text" name="user" ng-model="user" required ng-pattern="/[a-zA-Z]/">
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
  <span ng-show="myForm.user.$invalid">用户名是必须的。</span>
</span>
</p>
</form>
<script>
var app = angular.module(&#39;myApp&#39;, []);
app.controller(&#39;validateCtrl&#39;, function($scope) {
$scope.user = &#39;John Doe&#39;;
$scope.email = &#39;john.doe@gmail.com&#39;;
});
</script>
</body>
</html>
Copy after login


Related recommendations:

How to use regular expressions in JavaScript

Introduction to the use of regular expressions in C

Usage of regular expressions in JAVA

Some application cases of regular expressions

The above is the detailed content of The use of regular expressions in angularJS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template