Sanket Dorle
Sanket Dorle

Reputation: 107

How to validate angular2-signaturepad?

I am Using angular2-signaturepad.

I am trying to validate the signature pad. like this

savePad() {
      this.signature = this.signaturePad.toDataURL();
      if (this.signature != '' && this.signature == undefined) {
          //  this.signature = this.signaturePad.toDataURL();
          this.signature = '';
          let toast = this.toastCtrl.create({
              message: 'You have to Signature first.',
              duration: 3000,
              position: 'c'
          });
          toast.present();
      }else{
      this.signaturePad.clear();
          let toast = this.toastCtrl.create({
              message: 'New Signature saved.',
              duration: 3000,
              position: 'top'
          });
          toast.present();
      }
  }

this is my savepad() function.

I want this kind of functionality:

If signature pad is empty(save without signature) the toast want to come "You have to Signature first." else it will save successfully.

Is this Possible to validate angular2-signaturepad ?

or

am I doing something wrong ?

if is possible then please guide me ..!!

Upvotes: 1

Views: 1901

Answers (1)

Akhilesh Sehgal
Akhilesh Sehgal

Reputation: 186

You can check that the signature pad is empty or not by using isEmpty().
Use:

this.signaturePad.isEmpty()

This will return true/false.

Hope this will help.

Upvotes: 2

Related Questions