Skip to main content
Known Participant
May 7, 2024
Question

Form Field Format question

  • May 7, 2024
  • 2 replies
  • 1537 views

Hi All, 

If i apply a SSN(social Security number format) using below javascript, it allows alphabets to enter in the field, to correct that i have to manually set the format again in the field properties. I am not sure what makes the field to act like this. Below is the screenshot and JS .

 

var arr = ['clm_ssn', 'ee_ssn', 'patient_ssn', 'ssnp6',];
for (var i = 0; i < this.numFields; i++) {
var s = this.getField(this.getNthFieldName(i));
if (arr.indexOf(s.name) >= 0) {
s.setAction("Format", "AFSpecial_Format(3)");
s.setAction("Keystroke", "AFSpecial_KeystrokeEx(3)");
}
}

 

 

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
May 7, 2024

Where did you find that this is the right code for an SSN field?

Known Participant
May 7, 2024

When I run the script in action wizard it changes the format to Social security number, and if i type numbers it shows in the ssn format (XXX-XX-XXXX).  however it also allows the field to type alphabets and it changing to 2 hypens (screenshot). also I have attached the screenshot in previous chat with the format.

 

Bernd Alheit
Community Expert
Community Expert
May 7, 2024

The script changes the format of the fields.

Known Participant
May 7, 2024

Yes Bernd Alheit, Thats what i wanted the field format should be in SSN.  However it should not allow any alphabets in that field. In this case post changing the format to ssn it still allows to type alphabets. 

Bernd Alheit
Community Expert
Community Expert
May 8, 2024

The function AFSpecial_KeystrokeEx requires a mask as parameter.

Replace the 3.