Skip to content

Commit f425586

Browse files
authored
Create actionButtonScript.js
1 parent 028e0f0 commit f425586

File tree

1 file changed

+68
-0
lines changed
  • Client-Side Components/UI Actions/Field Review of User Record when on form using action button

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function onClickCheckDetails() {
2+
// Friendly helper for field normalization guidance
3+
g_form.hideAllFieldMsgs();
4+
g_form.clearMessages();
5+
6+
// --- Get Field values ---
7+
var firstName = g_form.getValue('first_name');
8+
var lastName = g_form.getValue('last_name');
9+
var title = g_form.getValue('title');
10+
var userId = g_form.getValue('user_name');
11+
var email = g_form.getValue('email');
12+
var businessPhone = g_form.getValue('phone');
13+
var mobilePhone = g_form.getValue('mobile_phone');
14+
15+
// --- Regex patterns ---
16+
var capitalRegex = /^[A-Z][a-zA-Z\s]*$/; // Names & titles start with a capital
17+
var emailRegex = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
18+
var phoneRegex = /^\d+$/;
19+
20+
var suggestions = [];
21+
22+
if (firstName && !capitalRegex.test(firstName)) {
23+
g_form.showFieldMsg('first_name', 'Suggestion: Start the name with a capital letter.', 'info');
24+
suggestions.push('First Name');
25+
}
26+
27+
if (lastName && !capitalRegex.test(lastName)) {
28+
g_form.showFieldMsg('last_name', 'Suggestion: Start the name with a capital letter.', 'info');
29+
suggestions.push('Last Name');
30+
}
31+
32+
if (title && !capitalRegex.test(title)) {
33+
g_form.showFieldMsg('title', 'Suggestion: Titles usually start with a capital letter.', 'info');
34+
suggestions.push('Title');
35+
}
36+
37+
if (!userId) {
38+
g_form.showFieldMsg('user_name', 'Suggestion: Do not keep the User ID empty.', 'info');
39+
suggestions.push('User ID');
40+
}
41+
42+
if (email && !emailRegex.test(email)) {
43+
g_form.showFieldMsg('email', 'Suggestion: Please use a valid email format like name@example.com.', 'info');
44+
suggestions.push('Email');
45+
}
46+
47+
if (businessPhone && !phoneRegex.test(businessPhone)) {
48+
g_form.showFieldMsg('phone', 'Suggestion: Use digits only avoid letters.', 'info');
49+
suggestions.push('Business Phone');
50+
}
51+
52+
if (mobilePhone && !phoneRegex.test(mobilePhone)) {
53+
g_form.showFieldMsg('mobile_phone', 'Suggestion: Use digits only avoid letters.', 'info');
54+
suggestions.push('Mobile Phone');
55+
}
56+
57+
/
58+
if (businessPhone && mobilePhone && businessPhone === mobilePhone) {
59+
g_form.showFieldMsg('phone', 'Work and mobile numbers appear identical, use different Numbers!', 'info');
60+
suggestions.push('Phone Numbers');
61+
}
62+
63+
if (suggestions.length > 0) {
64+
g_form.addInfoMessage('Quick review complete! Please check: ' + suggestions.join(', ') + '.');
65+
} else {
66+
g_form.addInfoMessage('looks good! Nicely formatted data.');
67+
}
68+
}

0 commit comments

Comments
 (0)