AnsweredAssumed Answered

How to add onclick attribute to the submit button?

Question asked by 82514 on Mar 13, 2015
Latest reply on Mar 13, 2015 by Sanford Whiteman
I am trying to validate two email fields to make sure they are the same. I already have the folowing code on the page in a custom HTML block but I need to know how I add an onclick function to the submit button. There doesn't seem to be a way to add code to an actual form or submit element.
 
<script type="text/javascript"> 
function checkEmail(email1,email2) { 
   var e1 = document.getElementById('email1').value; 
   var e2 = document.getElementById('email2').value; 

   if (e1 != e2) { 
      return true; 
   } 
   else 
   { 
     alert('Plerase verify the email address!'); 
    return false; 
   } 
</script> 

Outcomes