JavaScript error handling help - please!!?
-
Write JS 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 JS statements needed to check if the character is not a number or a non-alphanumeric character, or if you throw an error message. <script type="text/javascript"> function validateNumber(formObject) { var x=prompt("0",""); try { if(x>10) { throw "er1"; } else if(x<0) { throw "er2"; } else if(isNaN(x)) { throw "er3"; } } catch(er) { if(er=="er1") { alert("Error: The value is too high"); } if(er=="er2") { alert("Error: The value is too low"); } if(er=="er3") { alert("Error: The value is invalid"); } } </script> would that work for that? and then I do no understand this Write a custom error handling JS function called processErrors that handles a custom error by assigning it to the onerror event handler. Include the block of JS statements needed to pass the arguments sent by the JS interpreter into the processErrors function, send an alert message with the agreements, return, and write the event handler that calls the processErrors function.
-
Answer:
Try adding new variables and see if that helps.
Darian at Yahoo! Answers Visit the source
Related Q & A:
- I did something really bad and now i need help please help me.Best solution by Yahoo! Answers
- The accounting cycle? Help please?Best solution by Yahoo! Answers
- Psp custom firmware help. please?Best solution by Yahoo! Answers
- Msn signing in help please?Best solution by Yahoo! Answers
- Ice Skating Spin Help Please?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.