1

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 ..!!

Sanket Dorle
  • 117
  • 1
  • 12
  • What is suppose to be the problem ? Can you be more specific what you are trying to do ? – dim mik Jul 13 '17 at 10:58
  • If signature pad is empty(save without signature) the toast want to come "You have to Signature first." else it will save successfully. – Sanket Dorle Jul 13 '17 at 11:04

1 Answers1

2

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.

Akhilesh Sehgal
  • 186
  • 3
  • 16