0% found this document useful (0 votes)
36 views3 pages

DAY 12 13 Excercise

The document provides 12 programming exercises to practice JavaScript skills like form validation, string manipulation, number checking, and DOM manipulation. The exercises involve creating HTML forms and writing JavaScript code to validate input, perform calculations, and display output and errors. The goal is to get user input, check values, perform operations, and output results by manipulating the DOM and using JavaScript features like functions, if/else statements, and arrays.

Uploaded by

vishnuselva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

DAY 12 13 Excercise

The document provides 12 programming exercises to practice JavaScript skills like form validation, string manipulation, number checking, and DOM manipulation. The exercises involve creating HTML forms and writing JavaScript code to validate input, perform calculations, and display output and errors. The goal is to get user input, check values, perform operations, and output results by manipulating the DOM and using JavaScript features like functions, if/else statements, and arrays.

Uploaded by

vishnuselva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Javascript–Exercise

#1 Program
Create an html form with a textbox and button, Click the button to display a confirm box.

If Yes is pressed then display Given Text in textbox + " - u pressed Yes" and if you press No then display
Given text in textbox + " - U have pressed No"

Validation: If no text is given in the textbox then raise an alert “Please enter a text

#2 Program
Create an html form with a textbox and button and a div, Click the button to do the following. Use
separate function for each action

1. Find the length of the given text


2. Make the given text to upper case
3. Make the given text to lower case
4. Make the given text to InitCap

Print all the results inside a DIV

RESULTS:
Length:______
Upper:_________
Lowerr:________
InitCap:______

#3 Program
Create an html form to accept the below field and validate the data and print “Form Validation
success.”, if all the validation are success. And also print the sum and average of marks to the text boxes
inside the form.

1. Student ID (Aphla-nuberic, length = 5, First letter should be Alpha and rest should be a number)
2. Student name (Length <= 20,, no special characters except DOT(.) )
3. Age (Length = 2, only numbers)
3. Gender (Length = 1, only M/F)
4. English mark (Length = 6, only numbers and DOT(.) allowed)
5. Tamil mark (Length = 6, only numbers and DOT(.) allowed)
6. Maths mark (Length = 6, only numbers and DOT(.) allowed)
7. Scneice mark (Length = 6, only numbers and DOT(.) allowed)
8. Social mark (Length = 6, only numbers and DOT(.) allowed)

RESULTS:
Total Marks 
Average Marks 

#4 Program:
Create a HTML form which will have a text box and a button. Write a java script to get the input from the
text box and print the respective month in the alert box. If the number is not a valid month then raise an
error? – Use case statement for checking.
Javascript–Exercise

#5 Program
Create an html form that has 3 button with caption “hotcourses.com”, “hotcoursesusa.com” and
“myhotcourses.com”
When clicking on the buttons it will open the website ‘http://www.hotcourses.com’,
‘http://www.hotcoursesusa.com’ and ‘http://www.myhotcourses.com’ respectively in a 3 separate popup
window.

# 6 Program:
Create an html form with the text box to accept a color code and add the below data to the dropdown and
a button.

CODE NAME
1 Red
2 Blue
3 Green
4 Yellow
5 Orange
6 Black
7 White
8 Brown
9 Pink
10 Grey

Enter a color code and click the button, match the color code in the dropdown and check the color name
in the dropdown and print in the alert box.

#7 Program:
Create a HTML form which will have a text box and a button. Write a java script and do the following
and print the data inside textarea. Use separate function for each action

1. Reverse the String


2. Insert “=” after each character
3. Print the number count in the String

#8Program:
Create a HTML form which will have a 3 text box, dropdown and button. Add below value to the
dropdown, on clicking the button, Write a java script to get the input value from the first 2 text boxes and
do the following based on the value selected in the dropdown and store to 3 text box, USE separate
function for each action along with switch statement.

<Amstrong numbers>
<Perfect Numbers>
<Add All numbers>
<Odd numbers>
<Even numbers>

Based on the option selected process the data in textbox1 and textbox2 and show the result in textbox3.
Javascript–Exercise

#9 Program:
Create a HTML form with 2 dropdown (dropdown-1 and dropdown-2) in dropdown-1 add the below
datas and a button.

On clicking the button, using the JavaScript copy all the content from dropdown-1 to dropdown-2

CODE Fruits name


100 Tomato
200 Gourd
300 Cacao
400 Coconut
500 Jackfruit
600 Mango
700 Pineapple
800 Neem
900 Okra

#10 Program:
Create a HTML form and create 5 <DIV> and add some content in each div and hide all the divs, add
below data to a dropdown, on changing the dropdown show the selected div and hide all the divs

<Show student div>


<Show marks div>
<show attendance div>
<Show result div>
<ShowStaffs div>

#11 Program
Create a HTML form which will have a text box and a button. Write a java script to get the input from the
text box and print the below result in alert, if not number then raise error. Use (if-else)

a. age <5 print “This is a baby”


b. age >5 and <10 - print “This is a Children”
c. age >10 and <25 - print “This is a Student”
d. age >25 and <50 - print “This is a Young Man”
e. If age >50 - “This is a old man”

#12 Program:
Create a HTML form which will have a text box and a button. Write a java script to get the input from the
text box and print the below result in a single alert,

Date should be ??/??/???? if not then raise error else do the below - USE Array

1. Leap year?
2. No of days in the month?
3. Month name?

You might also like