I want to have the user enter their name as Last Name, First Name, with the comma. I need to be able to validate that there is a comma, figuring if there is not, they did not enter the name correctly and will give them a message saying such.
I have found a few things, but they don't seem to be working. Plus not sure where it would go, exit, change, validate, etc.?
I'm thinking something along the line of an e-mail validation, where it would check if there is text before and after the comma.
Thanks, Gary
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
use a regular expression in a script or the exit event to look for a comma.
This sample will check if there are at least two characters for the last name which are followed by a comma followed by at least two characters for the first name.
if (!$.rawValue.match(/\D{2}?\s*,+\s\D{2}?/g)) {
xfa.host.messageBox("No first name or last name or comma entered!");
}
Views
Replies
Total Likes
Hi,
use a regular expression in a script or the exit event to look for a comma.
This sample will check if there are at least two characters for the last name which are followed by a comma followed by at least two characters for the first name.
if (!$.rawValue.match(/\D{2}?\s*,+\s\D{2}?/g)) {
xfa.host.messageBox("No first name or last name or comma entered!");
}
Views
Replies
Total Likes
That's what I was looking for, thanks!
Views
Replies
Total Likes
Radzmar,
I have messed with your code above to try and make the script validate a field with:
Last, First MI
as of yet I haven't been able to figure out what is missing. I have tried changing the script to:
(/\D{2}?\s*,+\s\D{2}?/g+\s\D{1}?/g)
to account for the Middle Intial. A name having hyphens or any other digits isn't a problem. I would just like to check for the format [a-zA-Z0-9adgk][,]\s[a-zA-Z0-9adgk]\s[a-zA-Z0-9adgk] meaning
[anything], [anything] [anything]. None of these work however.
Any direction you could point me to get closer to the correct script would be appreciated. Thank you.
I am also getting an error in the console regardless of what is entered.
$.rawValue is null
7:XFA:form1[0]:#subform[0]:TextField1[0]:exit
TypeError: $.rawValue is null
7:XFA:form1[0]:#subform[0]:TextField1[0]:exit
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies