Top-Rated Free Essay
Preview

it238 r6 appendix c

Satisfactory Essays
243 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
it238 r6 appendix c
Associate Level Material
Appendix C

JavaScript® Code for Error Handling

Read the directions carefully and write JavaScript® code that addresses the requirements.

Copy your code directly into this appendix document and post your assignment.

1. Write JavaScript® code that anticipates and handles an error for an expected numeric field. This code is executed on keypress, and the entered value is saved for you in a variable called enteredChar. Include the try block of JavaScript® statements needed to check if the character is not a number or a nonalphanumeric character, or if you throw an error message.

2. Write a custom error handling JavaScript® function called processErrors that handles a custom error by assigning it to the onerror event handler. Include the block of JavaScript® statements needed to pass the arguments sent by the JavaScript® interpreter into the processErrors function, send an alert message with the arguments, return, and write the event handler that calls the processErrors function.

1. function numCheck() { var enteredChar = document.getElementById('numeric_field').value;

var pattern = new RegExp('/^\d+$/'); // numbers only match

if (pattern.test(enteredChar)) { alert("All good!"); } else { try { throw new Error("Invalid numerical character(s) given!"); } catch (e) { alert(e); } }
}
The html is as follows:
<form>
Enter Numeric Value: <input type="text" id="numeric_field" onkeypress="numCheck()">
</form>

2 function processErrors(errMessage, errURL, errLineNum) { window.alert("The file " + errURL + " generated the following error: " + errMessage + " on line " + errLineNum + ", and the caller is "+arguments.caller.toString()); return true;
}
window.onerror=processErrors;

You May Also Find These Documents Helpful

  • Satisfactory Essays

    IT210 R5 appendix b

    • 191 Words
    • 2 Pages

    The following example explains how to write a program that calculates the cost of painting a room. If the user provides the price of a gallon of paint; the number of square feet one gallon of paint covers; and the length, height, and width of the room, you can calculate the total cost of painting the room.…

    • 191 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Acc 220 Appendix C

    • 336 Words
    • 2 Pages

    |Direct materials budget |An estimate of the quantity and cost of direct materials to be |Analyzes the amount of raw materials that a manufacturing |…

    • 336 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Netw420 Week 4 lab report

    • 726 Words
    • 3 Pages

    Warning alerts represent items that require attention. When the EMS receives warning messages, they are logged like informational messages and a trouble ticket is created. Trouble ticket system can provide information on the number of alerts received and the speed with which these alerts are addressed.…

    • 726 Words
    • 3 Pages
    Powerful Essays
  • Satisfactory Essays

    The 2 ways they can deal with exception one to write code to elegantly handle the exception, in the…

    • 442 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    IT210 R5 Appendix D 2

    • 197 Words
    • 2 Pages

    Match the activity or purpose on the left with the appropriate description on the right by typing in the corresponding letter under the Answer column.…

    • 197 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    10. How can you eliminate the possibility that an application error is caused by another application or service running in the background…

    • 850 Words
    • 4 Pages
    Powerful Essays
  • Satisfactory Essays

    Appendix C Hca 210

    • 372 Words
    • 2 Pages

    | |makes sure that they know what will be happening to them. | | |…

    • 372 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Com150 Appendix B

    • 433 Words
    • 2 Pages

    7. Does this organization or individual have affiliations that might create a built-in bias toward the information? Explain your answer.…

    • 433 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Com/220 Appendix F

    • 353 Words
    • 2 Pages

    |persuasive essay? |explain why it’s important to use legal drugs for what they’re intended. |…

    • 353 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Javascript Error Handling

    • 255 Words
    • 2 Pages

    1. Write JavaScript code that anticipates and handles an error for an expected numeric field. This code is executed on keypress and the entered value is saved for you in a variable called enteredChar. Include the try block of JavaScript statements needed to check if the character is not a number or a non-alphanumeric character or if you throw an error message.…

    • 255 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Cjs240 Appendix D

    • 861 Words
    • 4 Pages

    Copy and paste the characteristics of the juvenile justice system and the adult justice systems into their respective columns. Place the characteristics that are relative to both the juvenile and adult systems into the column labeled “Both”.…

    • 861 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Psy270 Appendix D

    • 414 Words
    • 3 Pages

    Going to war and having a traumatic experience there can cause Post Traumatic Stress Disorder, otherwise known as PTSD. This can happen right away or this could even start years after the traumatic period is over. This can cause the person to do things that might be harmful to themselves or to other people.…

    • 414 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Hsm 210 Appendix E

    • 507 Words
    • 2 Pages

    In scenario one the prevention level being used is the Primary level of prevention. The reason I believe that this method is being used because the services offered through the agency are ones to prevent the abused women from being depressed and leading to other psychological disorders. In this particular scenario I wouldn’t do anything different, I think that the agency has a good plan in effect for dealing with potential hostile or violent situations. Instead of confronting the husband trying to talk rationally with him and defuse the situation while alarming the authorities is the best route for dealing with a person like that. In the case of the wife the programs offered through the agency promote self-worth and help prevent her from feeling bad about herself. Learning new job skills and healthy ways of thinking about oneself should prepare her for an independent lifestyle to provide for her and her children.…

    • 507 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    tudor statistics

    • 335 Words
    • 5 Pages

    var UA = confirm("Have you visited the 'Hair styles and Price list' page yet? Yes/No")…

    • 335 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    Java Script

    • 1085 Words
    • 5 Pages

    > key characteristics of function declarations is function declaration hoisting, whereby function declarations are read before the code executes.…

    • 1085 Words
    • 5 Pages
    Powerful Essays