Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
ig-validator angular2 sample
posted

Hi all!

Can anybody share with working ig-validator angular 2 config sample.

Thanks.

Parents Reply
  • 3995
    Offline posted in reply to Roman Romanov
    Hi Roman,
       constructor() {
           let self = this;
           this.opts = { onsubmit: true,
            successMessage: "Valid",
            onblur: false,
            create: function(e:any) {
                self.validatorRef = $(e.target).data("igValidator");
            },
            fields: [{
                required: true,
                selector: "#editor1",
                errorMessage: "Error",
                custom: function(value, fieldOptions){
                    var myRegEx  = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])([a-zA-Z0-9]{8,})$/;
                    var isValid = myRegEx.test(value);
                    return isValid;
                }
            }
           ]};
       }

    And once you've done so you could use the methods provided by the igValidator

       login() {
           console.log(this.validatorRef.isValid());
       }

    igniteui-angular2-quickstart-validator3.zip
Children
No Data