Sure, you can do this with JavaScript. Read this article at JavaScript Corner (link below) and downwload the example file. There is a Social Security number example that automatically inserts hyphens as the numbers are entered. You can inspect the script by selecting the field, Right Click, choose Properties, and look under the Format tab in the Custom Keystroke Script box. Of course, you will need a different script for the date and / instead of hyphens, but this shows you how symbols are auto-inserted between numbers during entry.
Thanks Dimitri, I found those examples and attempted to use the SSN script that you mentioned before I posted my first question.
If I copy and paste the script as it is, it works perfectly. As I begin to alter the code, it stops working. Also, I can't figure out how to replace the "-" with "/".
Can you give me some pointers for altering that code so that it will do what I need?
// Merge entered data var aRslt = event.value.split(""); aRslt.splice(event.selStart, event.selEnd - event.selStart, event.change); var strTest = aRslt.join("");
// Test for valid entry var rpat = /^\d{0,2}(\/\d{0,2}(\/\d{0,2})?)?$/; event.rc = rpat.test(strTest); } else { // In the WillCommit phase we want to validate the whole thing exactly var rpat = /^(\d{2}\/\d{2}\/\d{2})?$/; event.rc = (event.value == "") || rpat.test(event.value); }
Is there a way to set a field so that the dashes for the social security number are visible even before a user starts to type in their social security number?
Sure, you can do this with JavaScript. Read this article at JavaScript Corner (link below) and downwload the example file. There is a Social Security number example that automatically inserts hyphens as the numbers are entered. You can inspect the script by selecting the field, Right Click, choose Properties, and look under the Format tab in the Custom Keystroke Script box. Of course, you will need a different script for the date and / instead of hyphens, but this shows you how symbols are auto-inserted between numbers during entry.
[url=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/formatting_text_fields/]http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/formatting_text_fields/[/url]
Hope this helps,
Dimitri
WindJack Solutions
[url=http://www.windjack.com]www.windjack.com[/url]
Dimitri Munkirs
WindJack Solutions
pdfscripting.com