title: Angular2: Custom validation for fields with numbers only
body: <p>Im trying to do custom validation in angular 2, I have included what needed in my knowledge but Im unable to validate </p>
  
  <pre><code>import { FORM_DIRECTIVES, AbstractControl, ControlGroup
  ,FormBuilder,Control, Validators } from 'angular2/common';
  @Component({
  selector : 'cusValidate',
  template: `
   &lt;form [ngFormModel] = "myform" (ngSubmit) = "onSubmit()"&gt;
   &lt;lable&gt;Credit Card Number&lt;/lable&gt;
   &lt;div&gt;
   &lt;input type = "text" [ngFormControl] = "inputfield"/&gt;
   &lt;div [class.has-error] = '!inval'&gt;
    &lt;/div&gt;
   &lt;/div&gt;
   &lt;button type = "submit"&gt;Submit&lt;/button&gt;
   &lt;/form&gt;
  `,
  directives : [FORM_DIRECTIVES]
  
  })
  export class cusValidation{
  myform : ControlGroup;
  inputfield : AbstractControl;
  
  constructor(fb : FormBuilder){
     this.myform = fb.group({
          'inputfield' : ['' , Validators.compose([Validators.required
  ,this.formValidator])]
      })
     this.inputfield = this.myform.controls['inputfield']
  }
  
   formValidator(val : Control) :any {
       if(val.value.match(/^123/)){
           return {inval : true};
       }
   }
  
  onSubmit(){
      console.log('submit function called')
  }
  }
  bootstrap(cusValidation);
  </code></pre>
  
  <p>also validator function was in other file that i included but here its in class and im accessing using this.function, also how to apply appropriate twitter bootstrap </p>