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

Format MAC address field in form

New Here ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

I’m building a form that I need people to input there MAC address.  MAC Address is a fixed string of 12 characters with a colon in between each 2 characters.  How do I format a field that will automatically put the colon in as the person types the characters?

i was going to use the custom format category in the format tab.  Do you know a JavaScript that would do that?

TOPICS
PDF forms

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

LEGEND , Aug 19, 2018 Aug 19, 2018

The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits, separated by hyphens - or colons : so one needs to decide on the display format and provide a validation script that allows the entry of either separator character

The arbitrary mask allows special characters like "&", "?",  "<", "%" etc to be entered and not reported as invalid. This can be stopped by changing  the "X" to "O", the letter o, but it will not limit the alphab

...

Votes

Translate

Translate
Community Expert ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

You don't need a script. Under the Format tab select Special, Arbitrary Mask, and then enter this as the mask to use:

XX-XX-XX-XX-XX-XX

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
New Here ,
Aug 18, 2018 Aug 18, 2018

Copy link to clipboard

Copied

Wonderful, thank you!

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
LEGEND ,
Aug 18, 2018 Aug 18, 2018

Copy link to clipboard

Copied

You might want to add a validation script to check if any invalid characters are entered, or not enough characters.

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
Community Expert ,
Aug 18, 2018 Aug 18, 2018

Copy link to clipboard

Copied

The arbitrary mask will not allow the user to enter less characters than specified in it. It's all or nothing.

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
LEGEND ,
Aug 19, 2018 Aug 19, 2018

Copy link to clipboard

Copied

LATEST

The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits, separated by hyphens - or colons : so one needs to decide on the display format and provide a validation script that allows the entry of either separator character

The arbitrary mask allows special characters like "&", "?",  "<", "%" etc to be entered and not reported as invalid. This can be stopped by changing  the "X" to "O", the letter o, but it will not limit the alphabetical characters to a-f or A-F.

With the RegExp object provided within JavaScript, one can restrict each character position to specific characters or group of characters and even allows for a one of a group of characters for any position. So one can specify a range of numbers, a range of capitalized alphabetic characters, a range of lower case alphabetical characters, and special characters.

From PDF form field properties

Arbitrary Mask Changes the format category to Custom and makes another text field available, in which you can type a custom format. Use this option to specify which types of characters the user can enter in any given position, and how the data displays in the field.

A

Accepts only letters (A–Z, a-z).

X

Accepts spaces and most printable characters, including all characters available on a standard keyboard and ANSI characters in the ranges of 32–126 and 128–255.

O

The letter “O” accepts alphanumeric characters (A–Z, a-z, and 0–9).

9

Accepts only numeric characters (0–9).

For example, a mask setting of AAA--p#999 accepts the input BOE--p#767. A mask setting of OOOOO@XXX accepts the input vad12@3Up.

For the MAC address the allowable characters are the digits 0-9 and the upper or lower case alphabetical characters of A-F followed by either a  colon (":") or a dash ("-") which is repeated 5 times and then is just valid character pair at the end.

A possible validation script could be:

if(event.value !="" && /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]){2}$/.test(event.value) == false){

app.alert("Invalid MAC address entered " + event.value, 1, 0);

event.rc = false;

}

One could also add custom formatting and keystroke validation scripts.

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