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

The code sample as given below.

<!doctype html>
    <meta charset="utf-8">
    <title>ng pattern validation in angularjs</title>
    <script src=""></script>
    <form name="myform">
        <input type="number" require ng-pattern="/^\d{0,9}(\.\d{1,9})?$/">
        <input type="submit">

The out put look like as below image.


Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog -
My Books - Book 1 and Book 2 Powered by Blogger.