Re: Forms 2 - Disable input field

Rasmus_Bidstru1
Level 4

Forms 2 - Disable input field

Im trying to disable some fields in my forms2, so it just shows some data, and the user is not able to edit it.

I have tried through jQuery, its works local on my localhost, but not online. 

$(window).load(function() {
    var inputFields = $("#Email,#Phone,input:text");
    inputFields.prop( "disabled", true );
    inputFields.css({
        'background-color' : '#eaeaea',
        'color' : '#1f1f1f'
    }); 
 });

I have tried with a setTimeout aswell, without success. 
Is this an option within the form2 settings that i just missed?
Tags (1)
3 REPLIES 3
Rasmus_Bidstru1
Level 4

Re: Forms 2 - Disable input field

Found the solution.. is was with a setTimeout.

setTimeout(function () {
       var inputFields = $("input:text,#Email,#Phone");
        inputFields.prop("disabled", true);
    }, 50);
Anonymous
Not applicable

Re: Forms 2 - Disable input field

@Rasmus, using setTimeout is a good approach to give time for the Marketo form to load. 
Kenny_Elkington
Marketo Employee

Re: Forms 2 - Disable input field

Hey Rasmus,

You can user the MktoForm2.whenReady() callback to ensure the form is loaded instead of setTimeout when you're trying to hide the fields.  There's less variability in this for users with slow connections.