Skip to content

Commit 465c4c1

Browse files
committed
No fields without verification
1 parent df5cb8d commit 465c4c1

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/_includes/components/codepens/group-spec.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818

1919
var errors = [];
2020

21+
// Regular expression check name field is not empty
22+
var nameRegex = /.+/;
23+
if (!nameRegex.test(name)) {
24+
const nameError = document.getElementById("name-error");
25+
nameError.style.display = "block";
26+
const nameField = document.getElementById("name");
27+
nameField.style.outline = "2px solid red";
28+
errors.push("Name is invalid");
29+
} else {
30+
const nameError = document.getElementById("name-error")
31+
nameError.style.display = "none";
32+
const nameField = document.getElementById("name")
33+
nameField.style.outline = "";
34+
}
35+
2136
// Regular expression check for industry name
2237
var industryRegex = /^[A-Za-z-]+$/;
2338
if (!industryRegex.test(industry)) {
@@ -48,6 +63,20 @@
4863
employeesField.style.outline = "";
4964
}
5065

66+
// Add regular expression check to make sure plan field is not empty
67+
var planRegex = /.+/;
68+
if (!planRegex.test(plan)) {
69+
planError = document.getElementById("plan-error");
70+
planError.style.display = "block";
71+
plan = document.getElementById("plan");
72+
plan.style.outline = "2px solid red";
73+
errors.push("Plan is invalid");
74+
} else {
75+
const planError = document.getElementById("plan-error");
76+
planError.style.display = "none";
77+
const plan = document.getElementById("plan");
78+
plan.style.outline = "";
79+
}
5180

5281
// Add regular expression check for total billed
5382
var billedRegex = /^[0-9]+$/;
@@ -128,7 +157,8 @@
128157
<h3> Sample Group call</h3>
129158
<div class="sample-form">
130159
<label for="name">Name:</label>
131-
<input type="text" id="name" value="Twilio">
160+
<input type="text" id="name" value="Twilio" required>
161+
<span class="error-message" id="name-error">This field is required.</span>
132162
<label for="industry">Industry:</label>
133163
<input type="text" id="industry" value="Software">
134164
<span class="error-message" id="industry-error">Please enter a valid industry name, using only letters and hyphens.</span>
@@ -137,6 +167,7 @@ <h3> Sample Group call</h3>
137167
<span class="error-message" id="employees-error">Please enter a valid number of employees.</span>
138168
<label for="plan">Plan:</label>
139169
<input type="text" id="plan" value="Premium">
170+
<span class="error-message" id="plan-error">This field is required.</span>
140171
<label for="totalBilled">Total Billed:</label>
141172
<input type="text" id="totalBilled" value="34000000">
142173
<span class="error-message" id="billed-error">Please enter only numbers in the Total Billed field.</span>

src/_includes/components/codepens/identify-spec.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
emailField.style.outline = "";
5353
}
5454

55+
// Add regular expression check to make sure plan field is not empty
56+
var planRegex = /.+/;
57+
if (!planRegex.test(plan)) {
58+
planError = document.getElementById("plan-error");
59+
planError.style.display = "block";
60+
plan = document.getElementById("plan");
61+
plan.style.outline = "2px solid red";
62+
errors.push("Plan is invalid");
63+
} else {
64+
const planError = document.getElementById("plan-error");
65+
planError.style.display = "none";
66+
const plan = document.getElementById("plan");
67+
plan.style.outline = "";
68+
}
69+
5570
// Regular expression check for login #s
5671
var loginRegex = /^[0-9]+$/;
5772
if (!loginRegex.test(logins)) {

0 commit comments

Comments
 (0)