Create a web page that contains two text fields and a button labeled
Calculate. A user will enter his/her name and a number then click
Calculate button to get the result.
Use JavaScript to:
- validate the inputs:
The name should contain only letters. If not, display alert
message “Not correct. Enter a valid name”
The user should enter a correct number. If not, display alert
message “Not correct. Please enter a Number”,
- calculate the result:
The result is the sum from 1 to the entered number. For example, if the
entered number is 3, the result will be 10 (1+2+3= 6). When the user
clicks the Calculate button, the result should be displayed in a new
browser window, and written in green color.
التعليقات