Jon
Jon

Reputation: 1

Is it possible to validate a minimum signature was drawn on angular2-signaturepad?

I am using angular2-signaturepad to collect digital signatures in an angular 6 application. Some users are just drawing a simple dot or straight line. Is it possible to require users to enter more than a few dots or a line? I'm not trying to verify a name or full signature, just that they drew more than a tiny signature. Thank you in advance.

Upvotes: 0

Views: 1195

Answers (2)

Chad Hedgcock
Chad Hedgcock

Reputation: 11785

You can also validate for a minimum number of xy points in signaturePad.toData(). Here's an example validation method that looks for a minimum number of points.

hasComplexity(pad: SignaturePad, complexity?: number) {
  if (!complexity) {
    complexity = 10;
  }
  const points = pad.toData();
  const pointCount = [].concat.apply([], points).length;
  return points && pointCount >= complexity;
}

Usage example:

const isValid = this.hasComplexity(this.pad, 10);

Upvotes: 1

Vova Bilyachat
Vova Bilyachat

Reputation: 19504

My suggestion would be take canvas and check pixels

 var p = c.getImageData(x, y, 1, 1).data; 
 var hex = "#" + ("000000" + rgbToHex(p[0], p[1], p[2])).slice(-6);

So you should check how many are not empty.

Source

Upvotes: 0

Related Questions