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
angularjs url validation

angularjs url validation

This code sample are used to validate a web URL address which are given below.

Table of Contents.
  1. input type is equal to URL [type="url"].
  2. This is used a required element.
  3. This is not a valid URL.
  4. This validation is working on input keyup.
Example code as given below.

<!doctype html>
  <title>angularjs url validation</title>
  <script src=""></script>
    .error {
      color: red;
      var app = angular.module('myApp', []);

      app.controller('mainCtrl', function ($scope) {
          $scope.webURL = '';
<body ng-app="myApp">
  <ng-form name="myForm" ng-controller="mainCtrl">
      <div>URL :</div>
        <input type="url" name="webURL" ng-model="webURL" required>
        <span class="error" ng-show="myForm.webURL.$error.required">Required.</span>
        <span class="error" ng-show="myForm.webURL.$error.url">Not valid url.</span>


The result look like below image.


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 - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions