python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
ng-pattern validation in angularjs

ng-pattern validation in angularjs

The ng-pattern validation are use to validate the input fields with help of regular expressions. The regular expression can be number, email etc. If field is validated then return true otherwise return false.

In the below example, I am using the.
  1. input type="number" because I am going to validate the number.
  2. Required.
  3. ng-pattern attribute.
  4. number regular expression ["/^\d{0,9}(\.\d{1,9})?$/"]

Go to live demo link http://plnkr.co/edit/eWmokT?p=preview

The code sample as given below.

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>ng pattern validation in angularjs</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.js"></script>
</head>
<body>
    <form name="myform">
        <input type="number" require ng-pattern="/^\d{0,9}(\.\d{1,9})?$/">
        <input type="submit">
    </form>
</body>
</html>

The out put look like as below image.



ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions