willowsystems / jSignature

jQuery plugin - draw signature in browser.
720 stars 266 forks source link

Is empty #89

Open gerabu opened 6 years ago

gerabu commented 6 years ago

How to know if the signature pad is empty?

Binternet commented 6 years ago

Try console.log( $('#signature').jSignature("getData",'native').length > 0 );

Should return true if its signed.

gerabu commented 6 years ago

It is never truly empty because a guideline is always drawn

Binternet commented 6 years ago

Check the demo: https://willowsystems.github.io/jSignature/#/demo/

Run the command see it returns false Then draw and signature and run it again.

KeithETruesdell commented 6 years ago

I had the same issues, and it never returned false when there was a signature line. This 'issue' had been resolved from the original repo from brinley a couple years ago. This repo is about 6 years old. By changing over to the brinley repo and then doing something like....

if ((typeof jsSigData != 'undefined') && $("##js-signature").jSignature("isModified")) {
     jsSigDataValid = true;
}

you will make sure that there someone singed things.
This also works with the signature line, and in the situation that there is a clear button. If someone signs, then clears, it will return "false" as in nothing is modified. The method above will return true, regardless.

So go with the brinley one.