jeudi 13 septembre 2018

GST Validation Regex in Coffee Script

I am working on a project in Rails and AngularJS, in which i am writing my logic in Coffee Script. As i am new in this so unable to put validation of GSTIN.

For that i defined a globle variable:-

@gstnumber = ''

and write a function :-

@validateGST = (event) ->
 @gstnumber =  '/^([0][1-9]|[1-2][0-9]|[3][0-5])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$/'
 if @currentUser.gst_in != @gstnumber
  return false

This Function i write for ng-keypress in HTML File :-

<input type="text" placeholder="GST No" autocomplete="off" ng-keypress="ctrl.validateGST($event)" ng-model="ctrl.currentUser.gst_in"  class="guest-input" value=""  />

I am not able to find the reason why validation is not working please help ASAP.

Aucun commentaire:

Enregistrer un commentaire