Question: You have a server-side script called Ampersands.js that cannot handle any ampersands (&) in the form data. Write a script to convert all ampersands to
You have a server-side script called Ampersands.js that cannot handle any ampersands (&) in the form data. Write a script to convert all ampersands to and in the form field when the field loses focus element (blur).
A) Your script contains one (01) variable and two (02) functions:
1. Global variable: dom.
2. The function getElementAmpersand() that reads the field element by using the existing function getElementById() to access to the element using its id (field) specified in your HTML file by using the function addEventListener() to register the event handler, which takes three (03) arguments :
(a) the name of event as a string literal (here use "blur"), (b) the handler function convertAmpersands, and (c) the Boolean value false.
3. The function "convertAmpersands()" that converts all ampersands in the form field to " and " when the field loses focus ("blur").
4. The html document called "Ampersand.html", which invokes the "Ampersand.js" in the head section.
B) At the end of the JavaScript file, finish with this line to fire the load event when a resource and its dependent resources have finished loading: window.addEventListener( "load", getElementAmpersand, false );
Sample output:

Eile Edit View History Bookmarks I ools Help Enter some text that includes at least one & then click outside the input box. SC&SE Result is Enter some text that includes at least one & then click outside the input box SC and SE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
