These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Restricting Entries in a Text Field

Severus
Registered: Feb 8 2011
Posts: 2

I'm new to Acrobat forms; just finishing my second, using Acrobat 8. I have one field where I want to limit user entries to one of three letters. In other words, they can only enter C, N, or H in this particular field. Is there any way to do this? I already have a column of this field created and formatted, and am hoping I don't have to start over and replace it with a radio button.
 
Thanks!

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The exact code will depend upon if you are using Acrobat Forms Tools or LiveCycle Designer. Both products have a 'validation' option.

In Acrobat you write a custom JavaScript with all the control.

In LiveCycle Designer, you can chose either FormCalc or JavaScript and write a script the results in either a logical true for passing the validation or a logical false when the validation fails. For any validation method you also need to enable an option for the field and enter the text for the error.

George Kaiser

Severus
Registered: Feb 8 2011
Posts: 2
Thank you, George! I'm using Acrobat, not LiveCycle. Writing JavaScript is, unfortunately, not in the form field of my knowledge. I searched the Net for one I could copy and paste, but couldn't articulate my search terms well enough.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
// convert entry to upper case
event.value = event.value.toUpperCase;
// see if entered value is a 'C", 'H', or 'N'
if(/^CHN$/.test(event.value)){
// issue an alert
app.alert('Only "C", "H", or "N" are valid entries.\nPlease reenter.', 1, 0);
}

You could also just use a custom keystroke script to only accept those three letters.

event.value = event.value.toUpperCase();
if( /^[^CHN]$/.test(event.value) ){
event.rc = false;
app.alert('Only "C", "H", or "N" are valid entries.\nPlease reenter.', 1, 0);
app.beep();
}

Or just use a combo box with the trhee choices.

George Kaiser