SOLVED

Re: Clear Pre-populated form field only for certain values

Go to solution
Anonymous
Not applicable
We have some forms that only collect email address. All leads are automatically pushed to SFDC and since Last Name/Company are required, they are automatically set to "NEEDS INFO". When a lead fills in the next form, they are now seeing the ugly "NEEDS INFO" in the pre-populated fields.

I do not want to turn off pre-population becasue in most cases the values are correct. However, I would like to be able to clear the field if it contains "NEEDS INFO".

I tried this Javascript but it isn't working. Any ideas why or how I can do this? Thanks so much for your help!

<script type="text/javascript" src="/js/public/jquery-latest.min.js"></script>
<script type="text/javascript">
    // set no conflict mode for jquery
  var $jQ = jQuery.noConflict();

  $jQ(document).ready(function(){
  var CompanyField = $jQ("#Company");
  var LastNameField = $jQ("#LastName");
  if (CompanyField == "NEEDS INFO") 
     {
      $jQ('#Company').attr('value','')
     }
  if (LastNameField == "NEEDS INFO") 
     {
      $jQ('#LastName').attr('value','')
     }
  });
</script>
Tags (1)
1 ACCEPTED SOLUTION
Anonymous
Not applicable
Thanks, Kenny, you were absolutely right. I was using the old 1.0 forms jquery on a 2.0 form.

In case anyone is interested, here's the 2.0 version of the code:

<script>
  MktoForms2.whenReady(function (form){
    //Put your code that uses the form object here.
    var vals = form.vals();
     if(vals.LastName == "NEEDS INFO"){
      form.vals({"LastName":""});
    }
    if(vals.Company == "NEEDS INFO"){
      form.vals({"Company":""});
    }
  });
</script>

Regards,
Sheila

View solution in original post

3 REPLIES 3
Anonymous
Not applicable
Thanks, Kenny, you were absolutely right. I was using the old 1.0 forms jquery on a 2.0 form.

In case anyone is interested, here's the 2.0 version of the code:

<script>
  MktoForms2.whenReady(function (form){
    //Put your code that uses the form object here.
    var vals = form.vals();
     if(vals.LastName == "NEEDS INFO"){
      form.vals({"LastName":""});
    }
    if(vals.Company == "NEEDS INFO"){
      form.vals({"Company":""});
    }
  });
</script>

Regards,
Sheila
Kenny_Elkington
Marketo Employee
Hi Sheila,

Assuming you're using a Forms 2.0 form, you should use the forms 2.0 API: http://developers.marketo.com/documentation/websites/forms-2-0/  the .vals() and .setValues() methods will allow you to do this.
Josh_Hill13
Level 10 - Champion Alumni
I'd check with a developer or developers.marketo.com.

success@perkuto.com can help in a pinch.