Adding custom form validation | Community
Skip to main content
January 14, 2015
Question

Adding custom form validation

  • January 14, 2015
  • 7 replies
  • 2751 views
I need to make a small JavaScript/jQuery can compare the two input fields. I was led to believe thsi could be done by editing custom form validation. Where can I find this? How do I do this? 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

January 14, 2015
Check out the Forms documentation, and in particular example 4 on the page:
http://developers.marketo.com/documentation/websites/forms-2-0/
January 14, 2015
Thanks Murtza,

I cannot edit the embeded code. The window pops up and shows the Javascript. Howerer, it will not let me edit to. 

How can I now edit the Javascript now that I have found it?
January 14, 2015
You would have to add your custom JavaScript on the page that checks for when the form loads and then implement changes there. 
January 15, 2015
Ahh! Im confused :-/

To be clear, I want to trap this invalid email error on the page that I am on (before I go to the follow up page). I want the JavaScript to to call upon this email validation function as the user presses Submit.

I have a feeling it would look like this (see below)....an if/esle statement...but I do not know how to get into the form's code to edit it....

can you offer some advice?



<script type="text/javascript"> 
function checkEmail() { 
   var e1 = document.getElementById('Email').value; 
   var e2 = document.getElementById('confirmEmailAddress').value; 

   if (e1 != e2) { 
      return true; 
   } 
   else 
   { 
     alert('Please verify the email address!'); 
    return false; 
   } 

</script> 
 
 
and set the additional attribute of the submit button to
Code:
onsubmit=" return checkEmail('email1','email2');"

 
January 15, 2015
Hi Matt

I am using custom validation.
My steps is below.
1.Select "Embed Code"


2. Copy Embed Code


3. Past code at Landing Page HTML Element and Edit it.


Finish!

Takehiro
January 15, 2015
Thank you Takehiro

So what you are saying is that this change needs to be made on the landing page, not the form itself? 

I ask because the LP will not be a Marketo landing page and I will need to give this job to someone else. 
January 16, 2015
Unfortunately, we can not edit embed code in Forms2.0 directly.
It is read only.
But embed code run on other CMS.
Someone can edit embed code on your company's CMS also.