• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ScriptUI field validation

Engaged ,
Apr 24, 2020 Apr 24, 2020

Copy link to clipboard

Copied

Can a scriptUI dialog check if the value entered in the text field is valid?

Screen Shot 2020-04-24 at 5.53.59 PM.png

For example, if the field is empty, display an alert that the field can not be empty.

Screen Shot 2020-04-24 at 5.54.07 PM.png

 

 

TOPICS
Actions and scripting

Views

2.6K

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 1 Correct answer

Advocate , Apr 25, 2020 Apr 25, 2020

See this if it's okay for you.

var regExp = new RegExp();
win = new Window("dialog", "TEST",undefined);

var textInput =win.add("edittext", undefined, "TEXT");
textInput.characters = 20;
textInput.active = true;

closeBtn =win.add("button", undefined, "CLOSE");

closeBtn.onClick = function () {
if (textInput.text == "")
alert("ALERT !!!\nEMPTY EDITTEXT?");
else {
win.hide();
}
}

win.show();

 

Votes

Translate

Translate
Adobe
LEGEND ,
Apr 24, 2020 Apr 24, 2020

Copy link to clipboard

Copied

Yes, use edittext.onChanging() event to test as you type and edittext.onChange() to check when you leave the field. Put your validation code in another function that you call.

Votes

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
Advocate ,
Apr 25, 2020 Apr 25, 2020

Copy link to clipboard

Copied

See this if it's okay for you.

var regExp = new RegExp();
win = new Window("dialog", "TEST",undefined);

var textInput =win.add("edittext", undefined, "TEXT");
textInput.characters = 20;
textInput.active = true;

closeBtn =win.add("button", undefined, "CLOSE");

closeBtn.onClick = function () {
if (textInput.text == "")
alert("ALERT !!!\nEMPTY EDITTEXT?");
else {
win.hide();
}
}

win.show();

 

Votes

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
Engaged ,
Apr 25, 2020 Apr 25, 2020

Copy link to clipboard

Copied

Yes, this solution works. Thank you for providing the sample. Once the alert dialog is closed can the scriptUI insert the original textfiled value TEXT in the empty field?

Screen Shot 2020-04-25 at 10.44.55 AM.png

Votes

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
Advocate ,
Apr 25, 2020 Apr 25, 2020

Copy link to clipboard

Copied

that's fine.

var regExp = new RegExp();
win = new Window("dialog", "TEST",undefined);

var textInput =win.add("edittext", undefined, "TEXT");
textInput.characters = 20;
textInput.active = true;

closeBtn =win.add("button", undefined, "CLOSE");

closeBtn.onClick = function () {
if (textInput.text == "")
alert("ALERT !!!\nEMPTY EDITTEXT?");
else {
win.hide();
}
 textInput.text = "TEXT";
}

win.show();

 

Votes

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
Engaged ,
Apr 25, 2020 Apr 25, 2020

Copy link to clipboard

Copied

LATEST

Thank you much, that works. Can the filed focus return to highlight the TEXT in blue after the validation? 

I placed textInput.active = "true" below textInput.text = "TEXT" in the onClick function. But the filed focus does not dispaly.

Votes

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