Expand my Community achievements bar.

Mininum number of characters

Avatar

Former Community Member

I have a text field that requries a five digit number, the number will always have an I in front of the number.  How can I script the field to automatically display the I and give an error if five digits are not typed.

Thanks

1 Reply

Avatar

Level 6

In the exit event try following FormCalc code...

if (HasValue($)) then
$.rawValue = Replace($.rawValue, ".", "")
if (Left($.rawValue, 1) <> "I" and Len($.rawValue) < 6) then
  xfa.host.messageBox("At leaset 5 degits followed by I is required.")
elseif (Left($.rawValue, 1) <> "I") then
  xfa.host.messageBox("Value should start with I.")
elseif (Len($.rawValue) < 6) then
  xfa.host.messageBox("At leaset 5 degits followed by I is required.")
elseif (Ceil(Substr($.rawValue, 2, Len($.rawValue)-1)) == 0) then
  xfa.host.messageBox("At leaset 5 degits followed by I is required")
endif
endif