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

commitKey = 2 not working (Please Help!)

Participant ,
Jan 22, 2016 Jan 22, 2016

Okay, so I have a dropdown box (SName) and I have a textbox (Sender_Name). This is what I need to do. I need the dropdown box if anything is selected other than other the value of Sender_Name = the value of SName. Otherwise if other is selected from the dropdown then the textbox becomes visible and the value is the default value. However this is where I am having an issue. I need that value to change if the user enters text in (which I have working) but when you enter off the dropdown (SName) the commitKey for enter doesn't seem to be working. Tab and clicking off works correctly but enter is not. Any help is greatly appreciated. Thank you.

This portion of Javascript was put in the onBlur (run javascript) section of my dropdown field (SName):

var Name = this.getField('Sender_Name');
var SN = this.getField('SName');

if (((event.commitKey = 1) && (SN.value == "Other")&&(Name.value != Name.defaultValue)) || ((event.commitKey = 2) && (SN.value == "Other")&&(Name.value != Name.defaultValue)) || ((event.commitKey = 3) && (SN.value == "Other")&&(Name.value != Name.defaultValue))){

Name.value = "Please Enter a Sender Name";
}

This portion of Javascript was put in my format javascript for my dropdown field (SName):

var Name = this.getField('Sender_Name');
var SN = this.getField('SName');

if (SN.value=="Other") {    
Name.display = display.visible;
    }
else{
Name.value = SN.value;
Name.display = display.noView;
}

This protion of Javascript was put in the onFocus (run javascript) section of my textbox (Sender_Name):

if(event.target.value=="Please Enter a Sender Name"){

event.target.value ="";

}

This portion of Javascript was put in my format section of my textbox (Sender_Name):

function sname(){

if (!event.willCommit) {
var value = AFMergeChange(event);
if(!value) return;
if(!AFExactMatch(/^[a-zA-Z \ ]{0,38}/, value)) event.rc = false;
}
}

and obviously calling the keystroke in my textbox (Sender_Name):

sname();

TOPICS
Acrobat SDK and JavaScript
671
Translate
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

Participant , Jan 25, 2016 Jan 25, 2016

Got it working the way I need it to be.

function checkSenderName() {
    if (!event.willCommit) return;

    var Name = this.getField('Sender_Name');

    if (event.value == "Other") {
        Name.value = "Please Enter a Sender Name";
        Name.display = display.visible;
        Name.setFocus();
    } else {
        Name.value = event.value;
        Name.display = display.noView;
    }
}

Translate
LEGEND ,
Jan 22, 2016 Jan 22, 2016

This is wrong:

event.commitKey = 1

It should be:

event.commitKey == 1

Translate
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
Participant ,
Jan 22, 2016 Jan 22, 2016

I just changed the event.comitKeys to == but now it isn't working at all...

Translate
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
Participant ,
Jan 22, 2016 Jan 22, 2016

Anyone available to assist me with this issue? Please and thank you.

Translate
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
Participant ,
Jan 25, 2016 Jan 25, 2016
LATEST

Got it working the way I need it to be.

function checkSenderName() {
    if (!event.willCommit) return;

    var Name = this.getField('Sender_Name');

    if (event.value == "Other") {
        Name.value = "Please Enter a Sender Name";
        Name.display = display.visible;
        Name.setFocus();
    } else {
        Name.value = event.value;
        Name.display = display.noView;
    }
}

Translate
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