- Team Treehouse Project: Unit-3
- https://github.com/jcruzaxaeon/registration.git
- Create HTML, JavaScript for a registration form
- Indicate real-time errors for inputs: name, email, CC, Zip, CVV
- Create a universal listener callback function (
createListenerCb({validatorCb})
)validatorCb
( e.g.isValidName(name)
) returnsbool
. Callback functions that check for valid input.
- Create one validator for each input
- Create input-listeners:
{input}.addEventListener("input", createListenerCb({validatorCb}) )
nameInput.addEventListener( "input", createListenerCb(isValidName) )
- Show email-input-errors for:
- empty-field
- bad-format
- Lorem
- JavaScript, HTML (No: CSS)
- Central GitHub Repo
- WSL2 > Debian 10 > Linux CLI
- GreenGeeks Hosting
note
: merge into axaeon.comdetail
: git submodule foraxaeon.com
code
: 3tdescription
: Practice HTML-form creation, input-validationauthor
: jcruzcentralRepo
: https://github.com/jcruzaxaeon/registration.gitbranch
: mainorg
: Team TreehouseorgType
: Code Academycertification
: Fullstack JavaScript Techdegreelesson
: Unit Project 3topics
: JavaScript, HTMLtext
: Team Treehouse Unit Project 3. JavaScript, HTML practice.
- Lorem
- Lorem
November 27, 2023
: Modify readme. Push from host.Month DD, YYYY
- Lorem
- Ipsum
first | second |
---|---|
Lorem | Ipsum |
Lorem
The markdown below was automatically generated using JSDoc 3, and jsdoc-to-markdown.
- i :
Number
Integer index
- emailError :
Object
Track email-input error-type using blankMsg, formatMsg strings
- blankMsg :
String
Error message for email-input error: blank entry
- formatMsg :
String
Error message for email-input error: bad format
- otherJobInput :
HTMLInputElement
Text-input: Optional, custom job title input
- titleSelect :
HTMLSelectElement
Job title select
- colorSelect :
HTMLSelectElement
Color select
- designSelect :
HTMLSelectElement
T-Shirt design select
- activityFieldset :
HTMLFieldSetElement
Activity fieldset
- activityDiv :
HTMLDivElement
Activity container-div: Contains all activity elements
- activityCollection :
HTMLCollection.<HTMLLabelElement>
Each label holds one activity, i.e. all elements associated with one activity, notably, the checkbox-inputs
- paySelect :
HTMLSelectElement
Payment select
- form :
HTMLFormElement
Form
- nameInput :
HTMLInputElement
Text-input: Name
- emailInput :
HTMLInputElement
Email-input
- ccInput :
HTMLInputElement
Text-input: Credit card
- zipInput :
HTMLInputElement
Text-input: Zip code
- cvvInput :
HTMLInputElement
Text-input: CVV
- pay :
Array.<HTMLDivElement>
Each container-div holds one payment option, i.e. all elements associated with one payment option. (index. option):
- Credit Card
- Paypal
- Bitcoin
- titleSelectListener(titleSelectChange)
If 'other' job-title is selected, show and focus() on 'other-job-role' text-input element, else keep it hidden
- designSelectListener(designSelectChange)
If a design select option is set:
- Change color-select dispalyed message (option[0].textContent) to "Select color:"
- Focus() on color-select
- Enable color options available for selected t-shirt design
- activityListener(activityChange)
If change (check or uncheck) occurs on any activity checkbox-input:
- Re-initialize: (1) Reset total cost to $0, (2) Enable all checkbox-inputs
- Find a checked input: (1) Add price to total cost, (2) Disable other activities if time-conflicting
- paySelectListener(paySelectChange)
- Hide all payment containers
- Show selected type
- Select Option --- paySelect.value/pay[i].id --- i --- Type
- 1 --------------- credit-card ----------------- 0 --- Credit Card
- 2 --------------- paypal ---------------------- 1 --- Paypal
- 3 --------------- bitcoin --------------------- 2 --- Bitcoin
- createListener(validator)
Generalized 'input'-Listener Callback
- If input is not valid: Flag parent container as invalid
- [NOTE]: Show hints, Modify messages for specific email errors
- Else: hide hints, reset messages, reset flags
- nameInputListener(nameEInput)
Name text-input event listener
- emailInputListener(emailEInput)
Email-input event listener
- ccInputListener(ccEInput)
Credit card text-input event listener
- zipInputListener(zipEInput)
Credit card text-input event listener
- cvvInputListener(cvvEInput)
Credit card text-input event listener
- isValidName(name) ⇒
bool
Name validator: Argument for createListener()
- isValidEmail(email) ⇒
bool
Email validator: Argument for createListener()
- isValidCc(cc) ⇒
bool
Credit card validator: Argument for createListener()
- isValidZip(zip) ⇒
bool
Zip code validator: Argument for createListener()
- isValidCvv(cvv) ⇒
bool
CVV validator: Argument for createListener()
- formSubmitListener(formSubmit)
Form submit event listener: Verify valid form completion
- failure(e, elem)
Submit Event Failure Protocol
- isValidActivitySelection() ⇒
bool
Verify that at least 1 activity is selected
- "titleSelectChange"
Change in title select element
- "designSelectChange"
Change in design select element
- "activityChange"
Change in activity fieldset
- "paySelectChange"
Change in payment select element
- "nameEInput"
User input for name text-input element
- "emailEInput"
User input for email-input element
- "ccEInput"
User input for credit card text-input element
- "zipEInput"
User input for zip code text-input element
- "cvvEInput"
User input for CVV text-input element
- "formSubmit"
User submit event for form element
Integer index
Track email-input error-type using blankMsg, formatMsg strings
Error message for email-input error: blank entry
Error message for email-input error: bad format
Text-input: Optional, custom job title input
Job title select
Kind: global constant
Emits: titleSelectChange
Color select
T-Shirt design select
Kind: global constant
Emits: designSelectChange
Activity fieldset
Kind: global constant
Emits: activityChange
Activity container-div: Contains all activity elements
Each label holds one activity, i.e. all elements associated with one activity, notably, the checkbox-inputs
Payment select
Kind: global constant
Emits: paySelectChange
Form
Text-input: Name
Email-input
Text-input: Credit card
Text-input: Zip code
Text-input: CVV
Each container-div holds one payment option, i.e. all elements associated with one payment option. (index. option):
- Credit Card
- Paypal
- Bitcoin
If 'other' job-title is selected, show and focus() on 'other-job-role' text-input element, else keep it hidden
Kind: global function
Param | Type |
---|---|
titleSelectChange | Event |
If a design select option is set:
- Change color-select dispalyed message (option[0].textContent) to "Select color:"
- Focus() on color-select
- Enable color options available for selected t-shirt design
Kind: global function
Param | Type |
---|---|
designSelectChange | Event |
If change (check or uncheck) occurs on any activity checkbox-input:
- Re-initialize: (1) Reset total cost to $0, (2) Enable all checkbox-inputs
- Find a checked input: (1) Add price to total cost, (2) Disable other activities if time-conflicting
Kind: global function
Param | Type |
---|---|
activityChange | Event |
- Hide all payment containers
- Show selected type
- Select Option --- paySelect.value/pay[i].id --- i --- Type
- 1 --------------- credit-card ----------------- 0 --- Credit Card
- 2 --------------- paypal ---------------------- 1 --- Paypal
- 3 --------------- bitcoin --------------------- 2 --- Bitcoin
Kind: global function
Param | Type |
---|---|
paySelectChange | Event |
Generalized 'input'-Listener Callback
- If input is not valid: Flag parent container as invalid
- [NOTE]: Show hints, Modify messages for specific email errors
- Else: hide hints, reset messages, reset flags
Kind: global function
Param | Type | Description |
---|---|---|
validator | callback |
{bool} = validator({string}) |
Name text-input event listener
Kind: global function
Param | Type |
---|---|
nameEInput | Event |
Email-input event listener
Kind: global function
Param | Type |
---|---|
emailEInput | Event |
Credit card text-input event listener
Kind: global function
Param | Type |
---|---|
ccEInput | Event |
Credit card text-input event listener
Kind: global function
Param | Type |
---|---|
zipEInput | Event |
Credit card text-input event listener
Kind: global function
Param | Type |
---|---|
cvvEInput | Event |
Name validator: Argument for createListener()
Kind: global function
Param | Type |
---|---|
name | string |
Email validator: Argument for createListener()
Kind: global function
Param | Type |
---|---|
string |
Credit card validator: Argument for createListener()
Kind: global function
Param | Type |
---|---|
cc | string |
Zip code validator: Argument for createListener()
Kind: global function
Param | Type |
---|---|
zip | string |
CVV validator: Argument for createListener()
Kind: global function
Param | Type |
---|---|
cvv | string |
Form submit event listener: Verify valid form completion
Kind: global function
Param | Type |
---|---|
formSubmit | Event |
Submit Event Failure Protocol
Kind: global function
Param | Type | Description |
---|---|---|
e | formSubmit |
Prevent default submission behavior |
elem | HTMLInputElement |
input that failed validator test |
- failure(e, elem)
- ~inputContainer :
HTMLInputElement
- ~hint :
HTMLParagraphElement
- ~inputContainer :
- Input that failed validator test
Kind: inner constant of failure
hint - Holds invalid 'input' message
Kind: inner constant of failure
Verify that at least 1 activity is selected
Kind: global function
- isValidActivitySelection() ⇒
bool
- ~activityInput :
HTMLInputElement
- ~activityLabel :
HTMLLabelElement
- ~activityInput :
HTMLInputElement
- ~activityInput :
activityInput - Activity checkbox-input
Kind: inner property of isValidActivitySelection
activityLabel - activityInput container
Kind: inner property of isValidActivitySelection
activityInput - checkbox-input
Kind: inner property of isValidActivitySelection
Change in title select element
Change in design select element
Change in activity fieldset
Change in payment select element
User input for name text-input element
User input for email-input element
User input for credit card text-input element
User input for zip code text-input element
User input for CVV text-input element
User submit event for form element
Kind: event emitted