Access and secure data (26%) Flashcards
What type of input provides a color picker?
color
What type of input provides a date picker?
date
What type of input provides a date/time picker?
datetime
What type of input enables users to select a numeric month and year?
month
What type of input enables users to select a numeric week and year?
week
What type of input enables users to select a time of day?
time
What type of input forces the input to be numeric?
number
What type of input forces the input to be a properly formatted email address?
What type of input allows users to select a value within a range by using a slider bar?
range
What type of input formats entered data as a phone number?
tel
What type of input formats entered data as a properly formatted URL?
url
What type of input displays a radio button?
radio
What type of input displays a checkbox?
checkbox
What type of input displays a masked textbox for passwords?
password
What type of input displays a button?
button
What type of input resets all HTML elements within a form?
reset
What type of input posts the form’s data to the web server?
submit
What type of input displays a textbox?
text
What is the syntax to define a textarea with a specified number of columns and rows?
<textarea></textarea>
What formats does the url input accept?
Absolute URL’s with protocol unless overridden with the pattern attribute.
Which input cannot have a default value or be updated with JavaScript?
password
How do you default a checkbox input to be checked?
Add the checked attribute
How do you create a radio button group?
Set the name attributes of the radio inputs to the same value.
<tr>
<td>
Rate your experience:
</td>
<td>
<input></input> 1 - Very Poor
<input></input> 2
<input></input> 3
<input></input> 4
<input></input> 5 - Very Good
</td>
</tr>
What types of elements can act as buttons?
Anything can be a button if it has a click event or a mousedown and mouseup event.
What are the six default button types?
<input type="button" <button type="button" <input type="reset" <button type="reset" <input type="submit" <input type="submit"
Which button element provides default text for display?
input
The button element does not automatically provide default text to display as the input element does.
Which attribute is used to make a control read-only?
readonly
Which attribute is used to spellcheck the user’s input?
spellcheck
Which attribute is used to validate the user’s input against a regular expression?
pattern
Which inputs support the pattern attribute?
text, search, url, tel, email, and password
Which attribute is used to display watermark text?
placeholder
Which attribute makes the input required?
required
What character is used to enclose regular expressions in JavaScript?
The forward slash (/)
var s = $('#regExString').val(); var regExpression = /^[A-Z,a-z]\d[A-Z,a-z][\s{1}]?\d[A-Z,a-z]\d/; if (regExpression.test(s)) alert("Valid postal code."); else alert("Invalid postal code.");
What two methods are available on regular expression objects?
test and exec
What method on the regular expression object returns true if the string matches the pattern?
test
What method on the regular expression object returns the portion of the string that matches the pattern or null if not match is found?
exec
What function is used to determine if a value is not a number?
isNan
Returns true if the value passed in is not a number
What function is used to determine if a value is a number?
isFinite
Returns true is the value passed in is a number
Which attribute is used to restrict what data can be placed in an iframe element?
sandbox
What are the available values for the sandbox attribute of the iframe element?
”” (empty string), allow-same-origin, allow-top-navigation, allow-forms, allow-scripts
What value for the sandbox attribute of the iframe element applies all restrictions and is the most secure?
”” (empty string)
<iframe></iframe>
What value for the sandbox attribute of the iframe element treats iframe content as being from the same origin as the containing HTML document?
allow-same-origin
What value for the sandbox attribute of the iframe element allows iframe content to load content from the containing HTML document?
allow-top-navigation
What value for the sandbox attribute of the iframe element allows iframe content to submit forms?
allow-forms
What value for the sandbox attribute of the iframe element allows iframe content to run script?
allow-scripts
What object can be used to request JSON and XML from the server synchronously or asynchronously?
XMLHttpRequest
What events are available for handling on the XMLHttpRequest object?
readystatechange and timeout
Which event on the XMLHttpRequest object is used with asynchronous calls?
readystatechange
Which event on the XMLHttpRequest object is raised when the request can’t be completed?
timeout
What methods are available on the XMLHttpRequest object?
abort, getAllResponseHeaders, getResponseHeader, send, setRequestHeader, open
Which method of the XMLHttpRequest object cancels the current request?
abort
Which method of the XMLHttpRequest object gives a complete list of response headers?
getAllResponseHeaders
Which method of the XMLHttpRequest object returns the specific response header?
getResponseHeader
Which method of the XMLHttpRequest object makes the HTTP request and receives the response?
send
Which method of the XMLHttpRequest object adds a custom HTTP header to the request?
setRequestHeader
Which method of the XMLHttpRequest object sets properties for the request such as the URL, a user name, and a password?
open
What properties are available on the XMLHttpRequest object?
readyState, response, responseBody, responseText, responseType, responseXML, status, statusText, timeout, withCredentials
Which property of the XMLHttpRequest object gets the current state of the object?
readyState
Which property of the XMLHttpRequest object gets the response returned from the server?
response
Which property of the XMLHttpRequest object gets the response body as an array of bytes?
responseBody
Which property of the XMLHttpRequest object gets the response body as a string?
responseText
Which property of the XMLHttpRequest object gets the data type associated with the response, such as blob text, array-buffer, or document?
responseType
Which property of the XMLHttpRequest object gets the response body as an XML DOM object?
responseXML
Which property of the XMLHttpRequest object gets the HTTP status code of the request?
status
Which property of the XMLHttpRequest object gets the friendly HTTP text that corresponds with the status?
statusText
Which property of the XMLHttpRequest object sets the timeout threshold on the request in milliseconds?
timeout
Which property of the XMLHttpRequest object specifies whether the request should include user credentials?
withCredentials
Study this simple synchronous example of using the XMLHttpRequest object.
$("document").ready(function () { $("#btnGetXMLData").click(function () { var xReq = new XMLHttpRequest(); xReq.open("GET", "myXMLData.xml", false); xReq.send(null); #("#results").text(xReq.response); }); });
What are the parameters of the open method of the XMLHttpRequest object?
method, url, async, username, password
Which parameter of the open method of the XMLHttpRequest object is used to specify the HTTP method being used for the request: GET, POST, etc.?
method
Which parameter of the open method of the XMLHttpRequest object is used to specify the URL to make the request to?
url
Which parameter of the open method of the XMLHttpRequest object is used to specify a Boolean value to indicate whether the call should be made asynchronously?
async
If true, an event handler needs to be set for the onreadystatechanged
Which parameter of the open method of the XMLHttpRequest object is used to specify a user name if the destination requires credentials?
username
Which parameter of the open method of the XMLHttpRequest object is used to specify a password if the destination requires credentials?
password
What must be done to make an asynchronous call using the XMLHttpRequest object?
Add a handler for the readystatechanged event and pass true for the async parameter of the open method.
Which method of the XMLHttpRequest object actually makes the server request?
send
The open method does not make server requests. The send method does that.
When are the username and password sent during an XMLHttpRequest request?
The username and password are only passed to the server in response to a 401 HTTP code from the server.
What is the default value for the timeout property of the XMLHttpRequest object?
By default, the value for timeout is zero, which is infinite. A timeout value should always be specified.
What value must be specified for the timeout property of the XMLHttpRequest object in order to wait indefinitely for the server’s response?
Zero which is infinite.
Study this simple asynchronous example of using the XMLHttpRequest object.
var XMLHTTPReadyState_COMPLETE = 4; var xReq = new XMLHttpRequest(); xReq.open("GET", "myXMLData.xml", true); xReq.timeout = 2000; xReq.ontimeout = function () { $("#results").text("Request Timed out"); } xReq.onreadystatechange = function (e) { if (xReq.readyState == XMLHTTPReadyState_COMPLETE) { if (xReq.status = "200") { $("#results").text(xReq.response); } else { $("#results").text(xReq.statusText); } } } xReq.send(null);
What are the possible values for the readyState property of the XMLHttpRequest object?
0 - request not initialized 1 - server connection established 2 - request received 3 - processing request 4 - request finished and response is ready
What value of the readyState property of the XMLHttpRequest object indicates that the request is finished and the response is ready?
4
Study this simple example of using the XMLHttpRequest object to send data.
var xmlData = "<Person firstName='Rick' lastName='Delorme' hairColor='Brown' eyeColor='Brown' /> "; var xReq = new XMLHttpRequest(); xReq.open("POST", "/ReceiveXMLData.aspx", false); xReq.send(xmlData);
What object and method are used to serialize a JSON object into a string?
JSON.stringify
var person = { firstName: "Rick", hairColor: "Brown" }; var jsonString = JSON.stringify(person);
What object and method are used to deserialize a string into a JSON object?
JSON.parse
var req = new XMLHttpRequest(); req.open("GET", "MyJsonData.json", false); req.send(null); var jsonPerson = JSON.parse(req.responseText);
How should an XMLHttpRequest object be configure to send data serialized as binary?
Set the responseType property to ‘blob’.
var xReq = new XMLHttpRequest(); xReq.open("POST", "saveImage.aspx", false); xReq.responseType = 'blob'; xReq.send(data);
What object and method is used to deserialize binary data received from an XMLHttpRequest object?
URL.createObjectURL
var xReq = new XMLHttpRequest(); xReq.open("GET", "orange.jpg", false); xReq.responseType = 'blob'; xReq.send(null); var blob = xReq.response; document.getElementById("result").src = URL.createObjectURL(blob);
What is the syntax for the simplest form element?
<form>
| </form>
What is the syntax for submitting a form using jQuery?
$(“form”).submit(function () {
});
What jQuery method is used to serialize a form into a query string?
serialize
$("form").submit(function () { var qString = $(this).serialize(); alert(qString); $.ajax({ url: 'processSignUp.aspx', type: "POST", data: qString, success: function (r) { } }); return false; // Cancel the event. });
What must be specified for all HTML elements in order for them to be serialized using jQuery.serialize?
The name attribute
Which HTML elements will not be serialized by the jQuery.serialize method?
Elements without the name attribute and elements in an invalid state.