Question: Javascript Help Create a function called calculateTotals that gets the user entries, calculates the sales tax and totals, and displays those results in the text
Javascript Help
Create a function called calculateTotals that gets the user entries, calculates the sales tax and totals, and displays those results in the text boxes. Make sure to format the output correctly with two decimals.
Create an onload event handler. Within it, attached the calculateTotals function to the Calculate buttons click event. Test your application. Make sure the output values make sense.
Jack is still not very attentive so you need to validate his subtotal entries in the calculateTotals function. The business has never had a contract worth more than one million dollars
so the subtotal values should be greater than zero, but less than one million. If the amount is not valid, do not output the sales tax and total. You should also output an error message in the span element to the right of the subtotal input text box. The error message should be Subtotal should be numeric, greater than 0, and less than 1000000.
Jack is still distracted. He discovered a cool new mobile app developed by a studentso he tries to play it and do his work. Thus, you need to validate his tax rate entries in the calculateTotals function as well. The state and local government has a cap of 11% sales tax so the tax rate value should always be less than or equal to 11. It should also be a number. If the tax is not valid, do not output the sales tax and total. You should also output an error message in the span element to the right of the tax rate input text box. The error message should be Tax rate should be numeric and less than or equal to 11.
To make life easier on the user, please move the cursor to the Subtotal field when the application starts as well as when the user clicks on the Calculate button.
You also need to make the clear button work. When it is pressed, clear all four text boxes, clear the error messages, and move the cursor the to Subtotal field. Jill also wants to be able to click in the subtotal and tax rate text boxes and have the data clear in the text box and have the data clear in the text box.
index.html
Sales Tax Calculator
Enter Subtotal and Tax Rate and click "Calculate".
Enter order subtotalEnter sales tax rate (99.9)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
