Page 1 of 1

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

Posted: Tue Feb 03, 2015 10:07 pm
by danishsoomro

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.


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

Posted: Wed Feb 04, 2015 4:39 am
by Yurii Orishchuk

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.


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

Posted: Wed Feb 04, 2015 5:16 pm
by danishsoomro

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.


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

Posted: Thu Feb 05, 2015 4:04 pm
by Ihor Didevych

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.


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

Posted: Tue May 26, 2015 12:58 pm
by EJLD

useful, thks !