ng-pattern Number Validation using Angular Example

Today, We want to share with you ng-pattern Number Validation using Angular Example.In this post we will show you Angularjs ng-pattern form validation example, hear for Angularjs ng-pattern validation example we will give you demo and example for implement.In this post, we will learn about angularjs ng-pattern only numbers with an example.

ng-pattern Number Validation using Angular Example

There are the Following The simple About Angularjs ng-pattern with regular expressions Full Information With Example and source code.

As I will cover this Post with live Working example to develop Angularjs ng-pattern to allow only numbers example, so the ng-pattern angular 6 is used for this example is following below.

Read Also:  PHP Laravel carbon convert String To Date

AngularJS ng-pattern Number Validation Example

Angular is a platform for building mobile & desktop web Based user friendly and light weight applications.Angular,It’s TypeScript-based open-source Angularjs web application framework.

index.html

<!DOCTYPE html>
<html>
<head>
<title>AngularJs ng-pattern Form Validation Example AngularJS Tutorials, Demo with Example - Pakainfo.com</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript">
var webApplication = angular.module('ngpatternRootApplication', []);
webApplication.controller('ngpatternController', function ($scope) {
$scope.sendForm = function () {
$scope.message = "Form Validated";
};
});
</script>
</head>
<body>
<div ng-app="ngpatternRootApplication" ng-controller="ngpatternController">
<h3>AngularJs ng-pattern with Number Validation Example</h3>
<form name="memberForm" novalidate ng-submit="memberForm.$valid &&sendForm()">
Pin Code:<input type="text" name="pincode" ng-model="txtpin" ng-pattern="/^[0-9]{1,5}$/" required />
<span style="color:#c60000" ng-show="memberForm.pincode.$error.required"> Required! </span>
<span style="color:#c60000" ng-show="memberForm.pincode.$dirty&&memberForm.pincode.$error.pattern">Only Numbers Allowed, Maximum 5 Characters</span>
<hr /><hr />
<button type="submit">Submit Form</button><hr /><hr />
<span>{{message}}</span>
</form>
</div>
</body>
</html>

Web Programming Tutorials Example with Demo

Read :

Read Also:  How to validate URL Pattern in Angular?

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about ng-pattern for decimal number.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.