How does one delete element nodes in case the provided markup comes for example with empty attribute values like in the example below?
E.g. any image element with a missing src attribute needs to be deleted.
let elements = document.getElementsByTagName('img');
elements.forEach(function(element) {
  console.log(element);
  let src = element.src
  if (!ValidURL(src))
    element.parentNode.removeChild(element);
});
function ValidURL(str) {
  var pattern = new RegExp('^(https?:\/\/)?' + // protocol
    '((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|' + // domain name
    '((\d{1,3}\.){3}\d{1,3}))' + // OR ip (v4) address
    '(\:\d+)?(\/[-a-z\d%_.~+]*)*' + // port and path
    '(\?[;&a-z\d%_.~+=-]*)?' + // query string
    '(\#[-a-z\d_]*)?$', 'i'); // fragment locater
  if (!pattern.test(str)) {
    alert("Please enter a valid src.");
    return false;
  } else {
    return true;
  }
}<img id="image-1206-140" alt="" src="" class="ct-image img-proect" href="site.com">
<img id="image-1207-140" alt="" src="" class="ct-image img-proect" href="">
<img id="image-1207-140" alt="" src="" class="ct-image img-proect" href=""> 
    