danishsoomro
Posts: 0
Joined: Tue Feb 03, 2015 10:07 pm

Disable input text when select the check box. Thanks for any help

Hey guys, I'm stuck somewhere. If you anyone of you could help. Highly appreciate.

I have a checkbox in my app, which on "CHECKED" suppose to disable the input text below it.

I am running the following javascript on checkbox component and event is SELECTED
var Block = Apperyio("fundAmnt_input");
Block.disabled = true;

Am I doing something wrong. Thanks.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Disable input text when select the check box. Thanks for any help

Hello,

Here is a solution to disable input when check box is enabled.

  1. Activate checkbox component.

  2. Add "value change" event handler with action "javaScript".

  3. Populate it with following JS code:

    pre

    var checked = jQuery(this).find("input").prop("checked");

    //Note replace "mobiletextinput_351" with your input component name.
    if(checked)
    Apperyio("mobiletextinput_351").attr("disabled", "disabled")
    else
    Apperyio("mobiletextinput_351").removeAttr("disabled");

    /pre

    Regards.

danishsoomro
Posts: 0
Joined: Tue Feb 03, 2015 10:07 pm

Disable input text when select the check box. Thanks for any help

Thanks a lot Yuri for your time. It seems to not worked, I did as exactly you asked. OK so I will change the situation a bit. The checkbox is UNCHECKED by default on page load. There is a input field below it should be DISABLED by default on page load. Once user CHECKED it that will enable the INPUT FIELD.

I am sorry If I didnt make it clear last time or still not clear enough for you to understand. I tried myself .disabled = true which didnt work either.

Thanks.

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

Disable input text when select the check box. Thanks for any help

Hello,

Yurii told you correct and valid code
1) Please check your component names for input, this means instead of
mobiletextinput_351 you should place your input name, can you show us the screenshot where input name is shown and another one where you are placing your code ?
2) you can try to add some alerts

var checked = jQuery(this).find("input").prop("checked");
alert("State=" + checked);
//Note replace "mobiletextinput_351" with your input component name.
if(checked) {
Apperyio("mobiletextinput_351").attr("disabled", "disabled")
alert("Disabled");
}else{
Apperyio("mobiletextinput_351").removeAttr("disabled");
alert("Enabled");
}

Now you can see what is happening until runtime.

Return to “Issues”