Part 3 - Client side Validation and feedback Flashcards
(130 cards)
this javascript event occurs when an element gets focus
for example the user uses the Tab key to ‘tab’ to an input or clicks on a text input or its label.
describe the javascript event
focus
describe the following <input />
type and write its syntax
text
Allows us to collect a short amount of text from the user such as their name.
Syntax:
<input type=”text” />
1.Detect that the user has changed an input value through typing or clicking by responding to form events.
2.In JavaScript, obtain a reference to the input element and its value.
3.Compare that value against what is permitted for that input element and the business requirements of the application.
4.If the value matches the requirements, provide feedback to the user to confirm this.
5.If the value doesn’t match the requirements, provide a different message, indicating that the data is not suitable, and explaining what is needed.
6.If the user attempts to submit the form to the web server while some input values don’t match the requirements, the submission is blocked and a further message explaining what needs to be done is added.
7.If the user attempts to submit the form when all input values match the requirements, then the form submission is permitted.
describe 7 steps for user input validation
what is the syntax and parameters for the HTML label tag
syntax:
<label for="element_id">label text</label>
@param element_id the id of the element the label will be bound to
describe the following form element and its syntax
select
This is a form element that will create a drop down list of options of which we can select only one option from.
NOTE: However this can be extended to accept multiple selections if the multiple attribute is used
Syntax:
<select name=”” id=””> <option value=””>””</option> <option value=””>””</option> <option value=””>””</option> </select>
this will tie a regular expression to the start or end of the value
NOTE: These are placed within the forward slashes with the pattern
describe the
javascript regex anchor
this javascript event occurs when the value of an element changes at the point the change is completed
for example by clicking or by losing focus after entering text. This event is particularly useful for detecting that the user has made a new selection from a dropdown list, set of radio buttons or checkboxes.
describe the javascript event
change
This is a form element that can be used to collect a large piece of text from the user such as a comment or review
Syntax:
<textarea></textarea>
describe the form element and syntax of
textarea
method:
Returns the string value of the regular expression
describe the regex method
toString()
describe the following <input />
type and write its syntax
hidden
Allows us to create a hiddn field that will be sent to the server and hold some value we give it
Syntax:
<input type=”hidden” />
what are the three methods to
attach an event handler to a document event
this can be done by:
1. attaching the event hanler within the HTML
2. attaching it using javascript (via referencing the element)
3. attach In javascript using the addEventListener() method
regex:
/09$/
write a regex that will match values that end with 09
this is a form element that provides the textual description for the input tag. such as asking a question that will accompany the input
note: this is used in contrast to only using <p> tags
describe the HTML form element
<label></label>
describe the following attribute of the <input />
tag
Min=””
This <input />
attribute
specify a minimum value
NOTE: works only with number, range, date, datetime-local, month, time and week
This works just like the text input type but will hide the typed text
Syntax:
<input type=”password” />
describe the following <input />
type and write its syntax
password
using CSS write the syntax to select an input element which has the type attribute of text
syntax:
input[type=text] { declaration; }
syntax:
<form onsubmit="script">
@param script the script to be ran on submit
what is the syntax and parameters of the <form></form>
attribute
onsubmit
give 2 attributes of the form element
<textarea></textarea>
attributes include:
Rows = “” - the number of rows the textbox will have (in characters)
Cols = “” - the number of columns the textbox will have (in characters)
what is the syntax for creating a regex object in javascript
syntax:
/pattern/modifier(s);
Example:
var regex = /fox/i;
this is a special string of characters that will create a search pattern. it can then be tested against a string to check whether the pattern is contained within the string
what is a
regular expression (REGEX)
this <input />
attribute gives the input element a name
NOTE: this attribute is sent to the server on form submission
describe the following attribute of the <input />
tag
Name = “”
this can be accomplished using the HTML
<form></form>
how can we collect and then send user input back to a server
this is an object that holds the html element that triggered the event and all of its properties
describe
event.target
is a property of the event.target object and will return the value that is held by the HTML element
describe
event.target.value
tags