Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Trying to Disable/Enable Edittext field in UI but not Working!

Enthusiast ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

Hi Experts..

I'm trying hard to make edittext user input field to be disabled and enabled , it shouid be disable at first time until user interact with the UI and select the third radio button and it shouid be enabled! and i the user select another radio button it shouid be disabled but not working at all , here is my code (Part of Script UI) :

//Adding Page Number Group
var myPageNum = RadioPanel.add("group", undefined, {name: "myPageNum"});
myPageNum.preferredSize.width = 102;
myPageNum.orientation = "row";
myPageNum.alignChildren = ["right","right"];
myPageNum.spacing = 0;
myPageNum.margins =5; //Just Before Buttons
//myRadioGroup.orientation = "row";
myPageNum.add ("statictext", undefined, "Page Number:");
var myNum = myPageNum.add ("edittext", undefined, "5");
myNum.characters = 4;
//My edittext for PageNumbering is Disabled at first
myNum.enabled = false;

//Check if the typed is Number or not
myNum.onChange = checktext;
function checktext() { 
if (isNaN(Number(this.text))) {
alert("Are you Kidding! , Only numbers Accepted!");
myNum.text = ""
}
}

//Check For Enable or Disable Edittext field
radio3.onChange = checkradio3;
function checkradio3() { 
if (radio3.value == true)
if (myNum.enabled == false)
myNum.enabled = true;
else if  (radio3.value == false) {
myNum.enabled = false;
}
}

 also i tried direclty with if condition code :

if (radio3.value == true) {
myNum.enabled = true;
}
else if (radio3.value == false) {
myNum.enabled = false;
}

but no success!, every time i launch the script it will show (disabled edittext field) and if i try to select the third radio button (radio 3) nothing happened at all, please help and thanks in advance

Best

M.Hasanain

Best
M.Hasanain
TOPICS
Scripting

Views

202

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Enthusiast , May 01, 2021 May 01, 2021
Thanks Experts, I Figured the Problem my Self, i have to put Event listeners!//This is Important so we Can Listen to user Selection //Radio Event Listeners --------//Important to Let User Select Proper Radio--Radio 3 when Activated User Can Input radio1.onClick = function (){ myNum.enabled = radio3.value; } radio2.onClick = function (){ myNum.enabled = radio3.value; } radio3.onClick = function (){ myNum.enabled = radio3.value; }

Likes

Translate

Translate
Adobe Community Professional , May 01, 2021 May 01, 2021
Also, the ID dialog class has an enabling panel, and an integer input field, so you wouldn’t need listeners or a number test: //result variables var isEnabled, pNum; makeDialog(); /** * Construct the dialog */ function makeDialog(){ var theDialog = app.dialogs.add({name:"Page Dialog", canCancel:true}); with(theDialog){ with(dialogColumns.add()){ isEnabled = enablingGroups.add({checkedState:false, staticLabel:"Enter a Page Number:"}) with(isEnab...

Likes

Translate

Translate
Adobe Community Professional , May 01, 2021 May 01, 2021
Other good tips here, but this is another common design pattern. A simplified solution: var input; do { input = prompt("Enter a number"); } while(isNaN(input));

Likes

Translate

Translate
Enthusiast ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

Thanks Experts, I Figured the Problem my Self, i have to put Event listeners!

//This is Important so we Can Listen to user Selection
//Radio Event Listeners --------//Important to Let User Select Proper Radio--Radio 3 when Activated User Can Input
radio1.onClick = function (){
myNum.enabled = radio3.value;
}
radio2.onClick = function (){
myNum.enabled = radio3.value;
}

radio3.onClick = function (){
myNum.enabled = radio3.value;
}

 

Best
M.Hasanain

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

The integerEditbox only allows integers:

 

Screen Shot 28.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

Also, the ID dialog class has an enabling panel, and an integer input field, so you wouldn’t need listeners or a number test:

 

 

 


//result variables
var isEnabled, pNum;

makeDialog();

/**
* Construct the  dialog 
*/

function makeDialog(){
    var theDialog = app.dialogs.add({name:"Page Dialog", canCancel:true});
    with(theDialog){
        with(dialogColumns.add()){
            isEnabled = enablingGroups.add({checkedState:false, staticLabel:"Enter a Page Number:"})
            with(isEnabled){
                with(dialogColumns.add()){
                    staticTexts.add({staticLabel:"Page:"});
                }
                with(dialogColumns.add()){
                    pNum = integerEditboxes.add({editValue:1, minWidth:120});
                }
            }
        }
    }
	
    //the dialog results
    var res = theDialog.show();
    if(res == true){
        isEnabled = isEnabled.checkedState
        pNum = pNum.editValue;
        main()
	}else{
        theDialog.destroy();
    }
}


/**
* Run script.
* @Return void 
*/

function main(){
    alert("\nPanel Enabled = "+ isEnabled + "\nEntered number = " + pNum)
}




 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

Other good tips here, but this is another common design pattern. A simplified solution:

var input;
do {
   input = prompt("Enter a number");
} while(isNaN(input));

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

LATEST

Thanks so much indeed for you rob day and Brian.

Best

M.Hasanain

Best
M.Hasanain

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines