Currently, I am facing a challenge where our users need to input a company ID with leading and trailing spaces into 10 separate boxes. Instead of manually tabbing through each box, I am looking for a solution that allows them to paste the entire company ID from a spreadsheet or application and have it automatically parsed into the 10 boxes. The company ID can consist of numbers, letters, special characters, and spaces in any combination but must be exactly 10 characters long.
I have been struggling with this issue for some time now and would greatly appreciate any help from the community.
Below is the script I have developed so far:
var aView = Screen.CurrentView;
var str = aView.Fields("CompanyIDPaste").Value;
var strLen = str.length;
if (strLen < 10){
var str2 = "1111111111";
var str3 = str2.concat(str);
var str = str3.substring(str3.length - 10, str3.length);
}
// The rest of the code follows...
The current script successfully retains leading spaces but truncates trailing spaces. For example, "_ _ 345_abc_" gets parsed as "_ _ _ 345_abc" which is not ideal. I need the parsing to preserve the exact format as copied/pasted into the field.
This issue is really frustrating me, and any assistance you can provide would be extremely helpful.