我正在使用angular2-signaturepad .
我正在尝试验证签名板。 像这样
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();
}
}
这是我的 savepad()
函数。
我想要这种功能:
如果签名板为空(保存时不签名),则 toast 会显示“您必须先签名”。 否则保存成功。
这可以验证 angular2-signaturepad 吗?
或
我做错了什么吗?
如果可以的话 请指导我..!!
最佳答案
您可以使用 isEmpty() 检查签名板是否为空。
使用:
this.signaturePad.isEmpty()
这将返回真/假。
希望这会有所帮助。
关于javascript - 如何验证 angular2-signaturepad?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45078614/