如何在单击提交按钮之前检查图像是否已生成?

How do I check if image is generated before clicking submit button?

我正在创建一个 ASP.NET MVC5 应用程序,它利用 jSignature 来捕获用户的签名。看起来像这样,如果你不熟悉插件:

当用户点击 "Save" 时,他们的签名图像会生成并保存在签名板正下方的 <img/> 中:

我想做一些 front-end 验证以确保用户已单击 "save" 并因此在提交整个表单之前生成签名图像。如果可能的话,我想用 jQuery 来做到这一点。我有一个 pseudo-code mock-up 我 认为 这段代码应该看起来像的东西,但我无法将它变成 real-world 使用:

$("#entireFormSubmitButton").click(function(){
   if($("#imageOfSignature").doesNotExistOnPage){
      alert("Your signature is required before submitting this form");
      // also block the user from submitting form until signature provided
   }
});

我在编写这段自定义 front-end 验证时遇到了问题,因为 ASP.NET 已经为我完成了大部分工作,以确保填写所有其他必填字段。我可以得到一些帮助将其转换为工作代码吗?

 $("#entireFormSubmitButton").click(function(e){
       //block the user from submitting and check for signature
       e.preventDefault();
       if( $("#imageOfSignature").length == 0 || 
           $("#imageOfSignature").attr("src") == "" || 
           $("#date-of-birth-input").val() == ""){
          alert("Your message");
       } else {
           //all good, an image exists
           $(this).closest('form').submit();
       }
    });