Skip to main content

Posts

Showing posts from October, 2014

angularjs form validation

I am going to share the interesting topic to validate input form, This input form contains to Required input text field. input phone number . input web URL address. Email validation etc. All the above are used to  ng-pattern attribute to validate to each field. The Example code as given below <! doctype html > < html > < head >     < title > angularjs form validation </ title >     < script src =" http://code.angularjs.org/1.2.9/angular.min.js "></ script >     < style >         .error {             color : red ;         }     </ style >     < script >         var app = angular.module( 'myApp' , []);         app.controller( 'mainCtrl' , function ($scope) {             $scope.username = '' ;             $scope.word = /^\s*\w*\s*$/ ;             $scope.webURL = '' ;             $scope.phoneNumbr = /^\+?\d{2}[- ]?\d{3}[- ]?\d{5}$/ ;

AngularJs Phone Number Validation

This code sample are used to validate a  phone number using ng- required,  ng-pattern, ng- minlength and ng- maxlength  which  are given below in detail. Table of Contents. input type is equal to text i.e. [type="text"]. Used to required element. Used to ng-pattern attribute. Used to minlength and maxlength . place-holder control etc..  Example code as given below. <! doctype html > < html > < head >   < title > angularjs phone number validation </ title >   < script src ="http://code.angularjs.org/1.2.9/angular.min.js"></ script >   < style >     .error {       color : red ;     }   </ style >   < script >       var app = angular.module( 'myApp' , []);       app.controller( 'mainCtrl' , function ($scope) {           $scope.phoneNumbr = /^\+?\d{2}[- ]?\d{3}[- ]?\d{5}$/ ;       });   </ script > </ head > < body ng-ap

angularjs url validation

This code sample are used to validate a web  URL address which  are given below. Table of Contents. input type is equal to URL [type="url"]. This is used a required element. This is not a valid URL. This validation is working on input keyup . Example code as given below. <! doctype html > < html > < head >   < title > angularjs url validation </ title >   < script src ="http://code.angularjs.org/1.2.9/angular.min.js"></ script >   < style >     .error {       color : red ;     }   </ style >   < script >       var app = angular.module( 'myApp' , []);       app.controller( 'mainCtrl' , function ($scope) {           $scope.webURL = '' ;       });   </ script > </ head > < body ng-app ="myApp">   < ng-form name ="myForm" ng-controller ="mainCtrl">     < div >       &

angularjs required validation using ng-pattern

This code sample are used to validate a  required  field with single word which  are given below. Table of Contents. input type is equal to text [ type="text" ]. ng-pattern with single word. Required element tag. ng-model with two way binding. Example code <! doctype html > < html > < head >   < title > angularjs requiredvalidation </ title >   < script src ="http://code.angularjs.org/1.2.9/angular.min.js"></ script >   < style >     .error {       color : red ;     }   </ style >   < script >       var app = angular.module( 'myApp' , []);       app.controller( 'mainCtrl' , function ($scope) {           $scope.username = '' ;           $scope.singleword = /^\s*\w*\s*$/ ;       });   </ script > </ head > < body ng-app ="myApp">   < ng-form name ="myForm" ng-controller ="main

get custom header value in Web API 2 MVC 5 handler

Table of Contents $.ajax call with header request. API controller with added route-prefix , route and A ustomAuthFilter attribute. Authorization filter attribute. get custom header value using request header. This is the API base url as given below. var baseURL = "localhost://3456/API/BusinessEntity/GetBusinessEntityDetailByID/1" ; The $. ajax call with header request  $.ajax({             url: baseURL,             type: " POST ",                        data: {},             beforeSend: function (xhr) {                 xhr.setRequestHeader( "UserType" , "admin" );             },             async: true ,             cache: false ,             success: function (data) {             }      }); API Controller with CustomAuthFilter attribute namespace PCX.API {     [ RoutePrefix ( "API/BusinessEntity" )]     [ CustomAuthFilter ]     public class BusinessEntityController :