Skip to content

Commit df5cb8d

Browse files
committed
more verification, updating examples
1 parent 94213db commit df5cb8d

File tree

2 files changed

+59
-11
lines changed

2 files changed

+59
-11
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818

1919
var errors = [];
2020

21+
// Regular expression check for industry name
22+
var industryRegex = /^[A-Za-z-]+$/;
23+
if (!industryRegex.test(industry)) {
24+
const industryError = document.getElementById("industry-error");
25+
industryError.style.display = "block";
26+
const industryField = document.getElementById("industry");
27+
industryField.style.outline = "2px solid red";
28+
errors.push("Industry is invalid");
29+
} else {
30+
const industryError = document.getElementById("industry-error")
31+
industryError.style.display = "none";
32+
const industryField = document.getElementById("industry")
33+
industryField.style.outline = "";
34+
}
35+
2136
// Add regular expression check for number of employees
2237
var employeesRegex = /^[0-9]+$/;
2338
if (!employeesRegex.test(employees)) {
@@ -113,16 +128,17 @@
113128
<h3> Sample Group call</h3>
114129
<div class="sample-form">
115130
<label for="name">Name:</label>
116-
<input type="text" id="name" value="Fenty Beauty">
131+
<input type="text" id="name" value="Twilio">
117132
<label for="industry">Industry:</label>
118-
<input type="text" id="industry" value="Beauty">
133+
<input type="text" id="industry" value="Software">
134+
<span class="error-message" id="industry-error">Please enter a valid industry name, using only letters and hyphens.</span>
119135
<label for="employees">Employees:</label>
120-
<input type="text" id="employees" value="200">
136+
<input type="text" id="employees" value="20000">
121137
<span class="error-message" id="employees-error">Please enter a valid number of employees.</span>
122138
<label for="plan">Plan:</label>
123139
<input type="text" id="plan" value="Premium">
124140
<label for="totalBilled">Total Billed:</label>
125-
<input type="text" id="totalBilled" value="34000">
141+
<input type="text" id="totalBilled" value="34000000">
126142
<span class="error-message" id="billed-error">Please enter only numbers in the Total Billed field.</span>
127143
<input type="submit" class="button button-hollow" id="submit" onclick="showMessage(); showOutput()"
128144
value="See a sample group call">

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

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@
6767
loginsField.style.outline = "";
6868
}
6969

70+
// Regular expression check for street
71+
var streetRegex = /^\d+\s[A-z]+\s[A-z]+/;
72+
if (!streetRegex.test(street)) {
73+
const streetError = document.getElementById("street-error");
74+
streetError.style.display = "block";
75+
const streetField = document.getElementById("street");
76+
streetField.style.outline = "2px solid red";
77+
errors.push("Street is invalid");
78+
} else {
79+
const streetError = document.getElementById("street-error");
80+
streetError.style.display = "none";
81+
const streetField = document.getElementById("street");
82+
streetField.style.outline = "";
83+
}
84+
7085
// Regular expression check for city name
7186
var cityRegex = /^[A-Za-z\s-']+$/;
7287
if (!cityRegex.test(city)) {
@@ -97,6 +112,21 @@
97112
stateField.style.outline = "";
98113
}
99114

115+
// Regular expression check for country
116+
var countryRegex = /^[A-Z]{2}$/;
117+
if (!countryRegex.test(country)) {
118+
const countryError = document.getElementById("country-error");
119+
countryError.style.display = "block";
120+
const countryField = document.getElementById("country");
121+
countryField.style.outline = "2px solid red";
122+
errors.push("Country is invalid");
123+
} else {
124+
const countryError = document.getElementById("country-error");
125+
countryError.style.display = "none";
126+
const countryField = document.getElementById("country");
127+
countryField.style.outline = "";
128+
}
129+
100130
// Regular expression check for postcode
101131
var postcodeRegex = /^\d{5}$/;
102132
if (!postcodeRegex.test(postcode)) {
@@ -181,29 +211,31 @@
181211
<h4> Sample Identify </h4>
182212
<div class="sample-form">
183213
<label for="name">Name:</label>
184-
<input type="text" id="name" value="Dolly Parton">
214+
<input type="text" id="name" value="John Smith">
185215
<span class="error-message" id="name-error">Please enter your name.</span>
186216
<label for="email">Email:</label>
187-
<input type="text" id="email" value="dollyparton@fake-email.com">
217+
<input type="text" id="email" value="john-smith@gmail.com">
188218
<span class="error-message" id="email-error">Please enter a valid email address.</span>
189219
<label for="plan">Plan:</label>
190220
<input type="text" id="plan" value="Premium">
191221
<label for="logins">Logins:</label>
192222
<input type="text" id="logins" value="2">
193223
<span class="error-message" id="logins-error">Please enter only numbers in the 'Logins' field.</span>
194224
<label for="street">Street:</label>
195-
<input type="text" id="street" value="P.O. Box 150307">
225+
<input type="text" id="street" value="101 Spear Street">
226+
<span class="error-message" id="street-error">Please enter a valid street address, including the street name and number.</span>
196227
<label for="city">City:</label>
197-
<input type="text" id="city" value="Nashville">
228+
<input type="text" id="city" value="San Francisco">
198229
<span class="error-message" id="city-error">Please enter a valid city name in the 'City' field.</span>
199230
<label for="state">State:</label>
200-
<input type="text" id="state" value="TN">
231+
<input type="text" id="state" value="CA">
201232
<span class="error-message" id="state-error">Please enter a valid two-letter state code in all caps, like 'CA' for California.</span>
202233
<label for="postcode">Zip Code:</label>
203-
<input type="text" id="postcode" value="37215">
234+
<input type="text" id="postcode" value="94105">
204235
<span class="error-message" id="postcode-error">Please enter a valid five-digit zip code.</span>
205236
<label for="country">Country:</label>
206-
<input type="text" id="country" value="USA">
237+
<input type="text" id="country" value="US">
238+
<span class="error-message" id="country-error">Please enter a two-letter country code in all caps, like 'US' for United States.</span>
207239
<input type="submit" class="button button-hollow" id="submit" onclick="showMessage(); showOutput()" value="See a sample identify call">
208240
</div>
209241
</div>

0 commit comments

Comments
 (0)