Step-by-Step Textbook Solutions for Class 12 Computer Science Chapter 06 Client-Side Scripting Using JavaScript
Review structured textbook solutions for Class 12 Computer Science Chapter 06 Client-Side Scripting Using JavaScript. Built according to Kerala Board guidelines for the 2026-27 academic year, these downloadable answers support daily revision and problem-solving accuracy.
Download Chapter 06 Client-Side Scripting Using JavaScript Textbook Solutions PDF
Access the complete solution PDF for Class 12 Computer Science below. Regular practice with these targeted textbook answers builds familiarity with standard question patterns and helps secure higher marks in final school evaluations.
Previous Questions and Answers
Question 1: "TRUE and FALSE are used to represent boolean values." State whether the above statement is correct or not. (March 2016)
Answer:
Not correct in JavaScript. JavaScript is case sensitive, and its boolean values are written in lowercase as true and false; TRUE and FALSE in capitals are not boolean values in JavaScript.
Exam Tips:
a) JavaScript is case sensitive, so remember the exact lowercase spelling of keywords and values.
b) Give the reason along with the true/false decision.
Question 2: Develop a web page that implements a JavaScript function which takes two numbers as input and displays their product. (March 2016)
Answer:
<HTML>
<HEAD>
<TITLE>Product of two numbers</TITLE>
<SCRIPT Language="JavaScript">
function showProduct()
{
var n1, n2, p;
n1 = Number(document.frmprod.txtn1.value);
n2 = Number(document.frmprod.txtn2.value);
p = n1 * n2;
document.frmprod.txtp.value = p;
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="cyan">
<FORM NAME="frmprod">
<center>
Number 1
<input type="text" name="txtn1">
<br><br>
Number 2
<input type="text" name="txtn2">
<br><br>
Product
<input type="text" name="txtp">
<br><br>
<input type="button" value="Multiply" onClick="showProduct()">
</center>
</FORM>
</BODY>
</HTML>
Exam Tips:
a) Convert the text box values with Number() before multiplying; otherwise * still works, but + would join the text.
b) Give the form and the text boxes names so that the function can reach them as document.formname.boxname.value.
Question 3: Give the function in JavaScript that converts string type data containing numbers to number type. (March 2016)
Answer:
Number()
Exam Tips:
a) Example: Number("25") gives the number 25.
Question 4: a) Design a web page with a form tag which accepts a number in a text box and has another text box that should display either odd or even. Write a function in JavaScript to check whether the number is odd or even. (March 2016)
OR
b) Develop a web page that accepts a number after validation and prints the factorial of it.
Answer:
a)
<HTML>
<HEAD>
<TITLE>JavaScript</TITLE>
<SCRIPT Language="JavaScript">
function showevenodd()
{
var num, ans;
num = document.frmevenodd.txtnum.value;
if (num % 2 == 0)
ans = "even";
else
ans = "odd";
document.frmevenodd.txtevenodd.value = ans;
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="green">
<FORM NAME="frmevenodd">
<center>
Enter a number
<input type="text" name="txtnum">
<br><br>
The number is
<input type="text" name="txtevenodd">
<br><br>
<input type="button" value="Show" onClick="showevenodd()">
</center>
</FORM>
</BODY>
</HTML>
OR
b)
<html>
<head>
<title>JavaScript - factorial of a number</title>
<script language="JavaScript">
function showFact()
{
var n, i, fac = 1;
n = Number(document.frmfac.txtnum.value);
if (isNaN(n))
{
alert("Invalid number. Try again");
return;
}
for (i = 1; i <= n; i++)
fac = fac * i;
document.frmfac.txtans.value = fac;
}
</script>
</head>
<body bgcolor="cyan">
<form name="frmfac">
<center>
Number
<input type="text" name="txtnum">
<br><br>
Factorial
<input type="text" name="txtans">
<br><br>
<input type="button" value="show" onClick="showFact()">
</center>
</form>
</body>
</html>
Exam Tips:
a) Use the remainder operator: num % 2 == 0 means even.
b) In the factorial page, validate the input with isNaN() before the loop and use return to stop on invalid data.
c) Attempt only one of the two options (a or b).
Question 5: JavaScript provides a large number of built-in functions. (March 2016)
a) Name any two of them with an example.
b) The property which returns the size of the string is ______
Answer:
a) Two built-in functions:
1) alert(): displays a message in a dialogue box on the screen.
Example: alert("Welcome to JS");
2) isNaN(): checks whether the given value is not a number. It returns true if the value is not a number and false if it is a number.
Example: isNaN("BVM") returns true; isNaN(8172) returns false.
b) The length property.
Example:
x = "BVM";
alert(x.length); (displays 3)
Exam Tips:
a) Give the name, the purpose and one example for each function.
b) length is a property, so it is written without brackets.
Question 6: A virtual machine for executing JavaScript code is ______ (March 2017)
Answer:
JavaScript engine
Exam Tips:
a) Browsers such as Chrome (V8) and Firefox (SpiderMonkey) have their own JavaScript engines.
Question 7: Discuss six built-in functions used in JavaScript.
Answer:
1) alert(): displays a message (dialogue box) on the screen. Example: alert("Welcome to JS");
2) isNaN(): checks whether the given value is a number. It returns true if the value is not a number (NaN) and false otherwise. Examples: isNaN("BVM") returns true; isNaN(8172) returns false; isNaN("680121") returns false.
3) toUpperCase(): converts text to upper case. Example: var x = "bvm"; alert(x.toUpperCase()); displays BVM.
4) toLowerCase(): converts text to lower case. Example: var x = "BVM"; alert(x.toLowerCase()); displays bvm.
5) charAt(): returns the character at a particular position. Syntax: variable.charAt(index); the index of the first character is 0, of the second is 1, and so on. Example: var x = "HIGHER SECONDARY"; alert(x.charAt(4)); displays E.
6) length property: returns the number of characters in a string. Syntax: variable.length; Example: var x = "HIGHER SECONDARY"; alert(x.length); displays 16 (a space is also counted as a character).
Exam Tips:
a) Write the name, purpose and a one-line example for each of the six.
b) charAt() counts from 0, so charAt(4) is the fifth character.
Question 8: Design a procedure in JavaScript that takes two strings as input and displays the concatenated string as output. (March 2017)
Answer:
<html>
<head>
<title>JavaScript - join two strings</title>
<script language="JavaScript">
function join()
{
var str1, str2, str3;
str1 = document.frm.txt1.value;
str2 = document.frm.txt2.value;
str3 = str1 + str2;
document.frm.txt3.value = str3;
}
</script>
</head>
<body bgcolor="blue">
<form name="frm">
<center>
Enter string1
<input type="text" name="txt1">
<br>
Enter string2
<input type="text" name="txt2">
<br>
The concatenated string is
<input type="text" name="txt3">
<br>
<input type="button" value="ok" onClick="join()">
</center>
</form>
</body>
</html>
Exam Tips:
a) The + operator joins two strings (concatenation).
b) Show the complete page: function, text boxes and button.
Question 9: State whether the following statements are true or false: (May 2017)
a) JavaScript is the only client-side scripting language.
b) JavaScript is a case sensitive scripting language.
c) The keyword used to declare a variable in JavaScript is VAR.
Answer:
a) False. There are other client-side scripting languages, for example VBScript.
b) True. JavaScript is case sensitive; for example, the identifiers num and Num are different.
c) False. The keyword is var, written in lowercase, because JavaScript is case sensitive.
Exam Tips:
a) Give a short reason for each false statement.
b) Keywords in JavaScript (var, function, if, for) are always written in lowercase.
Question 10: Predict the output of the following code: (May 2017)
<HTML>
<BODY>
<SCRIPT Language="JavaScript">
var i, s = 0;
for (i = 1; i <= 10; i += 2)
s += i;
document.write("sum=" + s);
</SCRIPT>
</BODY>
</HTML>
Answer:
The output is sum=25.
The loop adds the odd numbers 1, 3, 5, 7 and 9 (i starts at 1 and increases by 2 until i is greater than 10): 1 + 3 + 5 + 7 + 9 = 25.
Exam Tips:
a) Trace the loop values of i and s in a small table to show your working.
b) document.write prints the text sum= followed by the value of s.
Practice Questions and Answers
Question 11: Develop a web page to display the following screen. (Figure: a page with a text box labelled "Enter a number", a second text box labelled "Product upto the limit" and a Show button; for the input 5 the second box shows 120.) The user can enter a number in the first text box. On clicking the Show button, the product of all numbers from 1 to the entered limit should be displayed in the second text box.
Answer:
<HTML>
<HEAD>
<TITLE>JavaScript</TITLE>
<SCRIPT Language="JavaScript">
function showProduct()
{
var num, ans = 1, i;
num = document.frmprod.txtnum.value;
for (i = 1; i <= num; i++)
ans = ans * i;
document.frmprod.txtprd.value = ans;
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="CYAN">
<FORM NAME="frmprod">
<center>
Enter the limit
<input type="text" name="txtnum">
<br><br>
Product upto the limit
<input type="text" name="txtprd">
<br><br>
<input type="button" value="Show" onClick="showProduct()">
</center>
</FORM>
</BODY>
</HTML>
Exam Tips:
a) The product of 1 to n is the factorial of n, so start the product variable at 1 (not 0).
b) Use a for loop from 1 to the limit and multiply in each step.
Question 12: Develop a web page to display the following screen. (Figure: a page with a text box labelled "Enter a number", a second text box labelled "The number is" and a Show button; for the input 241 the second box shows odd.) On clicking the Show button, Even or Odd should be displayed in the second text box depending on whether the number is even or odd.
Answer:
<HTML>
<HEAD>
<TITLE>JavaScript</TITLE>
<SCRIPT Language="JavaScript">
function showevenodd()
{
var num, ans;
num = document.frmevenodd.txtnum.value;
if (num % 2 == 0)
ans = "even";
else
ans = "odd";
document.frmevenodd.txtevenodd.value = ans;
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="green">
<FORM NAME="frmevenodd">
<center>
Enter a number
<input type="text" name="txtnum">
<br><br>
The number is
<input type="text" name="txtevenodd">
<br><br>
<input type="button" value="Show" onClick="showevenodd()">
</center>
</FORM>
</BODY>
</HTML>
Exam Tips:
a) A number is even when num % 2 equals 0; otherwise it is odd.
b) Give names to the form and to both text boxes so that the function can use them.
Question 13: Develop a web page to display the following screen. (Figure: a page with a text box labelled "Enter age" and a Show button; for the input Seventeen a message box shows Invalid Age.) The user can enter an age in the text box. If the user enters letters instead of a number, then on clicking the Show button the message "Invalid Age" should be displayed. Otherwise the message "Correct Data" should be displayed.
Answer:
<HTML>
<HEAD>
<TITLE>JavaScript</TITLE>
<SCRIPT Language="JavaScript">
function showvalid()
{
var age;
age = document.frmvalid.txtage.value;
if (isNaN(age))
alert("Invalid Age");
else
alert("Correct Data");
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="cyan">
<FORM NAME="frmvalid">
<center>
Enter age
<input type="text" name="txtage">
<br><br>
<input type="button" value="Show" onClick="showvalid()">
</center>
</FORM>
</BODY>
</HTML>
Exam Tips:
a) isNaN() returns true when the value is not a number, which is exactly the Invalid Age case.
b) Use alert() to show the message box.
Question 14: Develop a login page as shown in the following figure. (Figure: a page with a text box labelled "User Name", a password box labelled "Password" and a Show button; a message box shows Correct Data for valid input.) The page must contain one text box for entering the user name and one password box for entering the password. The user name must contain at least 4 characters and the password must contain at least 6 characters. The first two characters in the password must be numbers. On clicking the Show button, if valid data are given in the boxes, the message "Correct Data" should be displayed. Otherwise the message "Wrong Data" should be displayed.
Answer:
<HTML>
<HEAD>
<TITLE>JavaScript - login</TITLE>
<SCRIPT Language="JavaScript">
function showValid()
{
var nam, pas;
nam = document.frmlogin.txtname.value;
pas = document.frmlogin.txtpass.value;
if (nam.length < 4)
{
alert("The User name must contain at least 4 characters. Try again");
return;
}
if (pas.length < 6)
{
alert("The password must contain at least 6 characters. Try again");
return;
}
if (isNaN(pas.charAt(0)) || isNaN(pas.charAt(1)))
{
alert("The first two characters in the password must be numbers. Try again");
return;
}
if (nam == "bvmhss" && pas == "123bvmhss")
alert("Correct Data");
else
alert("Wrong Data");
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="cyan">
<FORM NAME="frmlogin">
<center>
User Name
<input type="text" name="txtname">
<br><br>
Password
<input type="password" name="txtpass">
<br><br>
<input type="button" value="show" onclick="showValid()">
</center>
</FORM>
</BODY>
</HTML>
Exam Tips:
a) The length property gives the number of characters; use it for the minimum length checks.
b) charAt(0) and charAt(1) give the first two characters of the password; isNaN() checks that they are numbers.
c) The user name and password compared at the end (bvmhss and 123bvmhss) are sample values.
Question 15: Develop a web page to implement a simple calculator. The page should have two text boxes to enter two numbers. It should also have 4 buttons to add, subtract, multiply and divide the two numbers. The answer should be displayed in a third text box on clicking the button. (Figure: a page with text boxes Number1, Number2 and Answer, and four buttons +, -, *, /; for 1 and 2 with the divide button the answer is 0.5.)
Answer:
<HTML>
<HEAD>
<TITLE>JavaScript - Simple Calculator</TITLE>
<SCRIPT Language="JavaScript">
function showAdd()
{
var num1, num2, ans;
num1 = Number(document.frmcalc.txtnum1.value);
num2 = Number(document.frmcalc.txtnum2.value);
ans = num1 + num2;
document.frmcalc.txtans.value = ans;
}
function showSub()
{
var num1, num2, ans;
num1 = Number(document.frmcalc.txtnum1.value);
num2 = Number(document.frmcalc.txtnum2.value);
ans = num1 - num2;
document.frmcalc.txtans.value = ans;
}
function showMul()
{
var num1, num2, ans;
num1 = Number(document.frmcalc.txtnum1.value);
num2 = Number(document.frmcalc.txtnum2.value);
ans = num1 * num2;
document.frmcalc.txtans.value = ans;
}
function showDiv()
{
var num1, num2, ans;
num1 = Number(document.frmcalc.txtnum1.value);
num2 = Number(document.frmcalc.txtnum2.value);
ans = num1 / num2;
document.frmcalc.txtans.value = ans;
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="cyan">
<FORM NAME="frmcalc">
<center>
Number1
<input type="text" name="txtnum1">
<br><br>
Number2
<input type="text" name="txtnum2">
<br><br>
Answer
<input type="text" name="txtans">
<br><br>
<input type="button" value="+" onClick="showAdd()">
<input type="button" value="-" onClick="showSub()">
<input type="button" value="*" onClick="showMul()">
<input type="button" value="/" onClick="showDiv()">
</center>
</FORM>
</BODY>
</HTML>
Exam Tips:
a) Write one small function for each button and call it from the onClick event.
b) Use Number() to convert the text box values to numbers; otherwise + would join the two texts.
Assess Questions and Answers
Question 16: Write the value of the variable z in each of the following:
a) var x, y, z; x = 5; y = 3; z = ++x - y--;
b) var x, y, z; x = "12"; y = "13"; z = x + y;
c) var x, y, z; x = 20; y = 8; x %= y; z = x++;
d) var x, y, z; x = 1; y = 4; z = !(x < y);
e) var x, y, z; x = 5; y = 6; z = (x > y) || (y % 2 == 0);
Answer:
a) ++x makes x = 6 first, and y-- uses the old value 3 in the expression. So z = 6 - 3 = 3.
b) Both x and y are strings, so + joins (concatenates) them. z = "12" + "13" = "1213".
c) x %= y means x = x % y, so x = 20 % 8 = 4. Then z = x++ first assigns the current value of x, so z = 4 (afterwards x becomes 5).
d) z = !(1 < 4) = !(true) = false.
e) z = (5 > 6) || (6 % 2 == 0) = false || (0 == 0) = false || true = true.
Exam Tips:
a) Prefix ++x changes the value first and then uses it; postfix x++ uses the value first and then changes it.
b) If one operand of + is a string, the other is also treated as a string and the result is a string.
c) Write each step of the evaluation to earn the marks.
Question 17: Predict the output of the following:
a)
<HTML>
<BODY>
<SCRIPT Language="JavaScript">
var i;
for (i = 10; i >= 1; i--)
document.write(i + "<BR>");
</SCRIPT>
</BODY>
</HTML>
b)
<HTML>
<BODY>
<SCRIPT Language="JavaScript">
var i, s = 0;
for (i = 1; i <= 100; i += 2)
s += i;
document.write("Sum = " + s);
</SCRIPT>
</BODY>
</HTML>
c)
<HTML>
<BODY>
<SCRIPT Language="JavaScript">
var n, s = 0;
n = 0;
while (n <= 50)
{
s = s + n;
n = n + 5;
}
document.write("Sum = " + s);
</SCRIPT>
</BODY>
</HTML>
d)
<HTML>
<BODY>
<SCRIPT Language="JavaScript">
var n, f = 1;
n = 5;
while (n > 0)
{
f = f * n;
n--;
}
document.write("Product = " + f);
</SCRIPT>
</BODY>
</HTML>
Answer:
a) The numbers 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 are displayed one below the other (each on a new line because of the BR tag).
b) The output is Sum = 2500, the sum of the odd numbers 1 + 3 + 5 + ... + 99.
c) The output is Sum = 275, the sum of the multiples of 5 from 0 to 50 (0 + 5 + 10 + ... + 50).
d) The output is Product = 120, that is 5 factorial (5 x 4 x 3 x 2 x 1).
Exam Tips:
a) Trace each loop with its starting value, condition and step.
b) Loop (a) counts down with i--, loop (b) adds 2 each time, loop (c) adds 5 each time and loop (d) multiplies while decreasing n.
Question 18: The following is an HTML code segment in a web page. Fill in the blank to store the value of the text box in the variable n.
<FORM Name="frmStud">
<INPUT Type="text" Name="studentName">
...
var n;
n = __________;
Answer:
n = document.frmStud.studentName.value;
Exam Tips:
a) The pattern is document.formname.textboxname.value; the names are case sensitive, so use them exactly as in the form.
Question 19: Suppose you have written a JavaScript function named checkData(). You want to execute the function when the mouse pointer is just moved over the button. How will you complete the following to do the same?
<INPUT Type="button" _________ = "checkData()">
Answer:
<INPUT Type="button" onMouseEnter="checkData()">
Exam Tips:
a) onMouseEnter (or onMouseOver) fires when the pointer moves over the element; onClick fires on a mouse click.
Question 20: Explain the <SCRIPT> tag and its attributes.
Answer:
Scripts are small programs embedded in HTML pages. The <SCRIPT> tag is used to write scripts inside a page.
1) The Language attribute specifies the name of the scripting language used.
2) The Src attribute gives the name of an external script file (for example check.js) when the script is kept in a separate file.
Example:
<SCRIPT Language="JavaScript">
...
</SCRIPT>
Exam Tips:
a) Write the tag with its attribute as a small example.
b) Remember that the closing tag </SCRIPT> is compulsory.
Question 21: Write the syntax of the built-in functions in JavaScript and explain them with examples.
Answer:
1) alert(): displays a message (dialogue box) on the screen. Example: alert("Welcome to JS");
2) isNaN(): checks whether the given value is a number. It returns a Boolean value: true if the value is not a number (NaN) and false otherwise. Examples: isNaN("BVM") returns true; isNaN(8172) returns false; isNaN("680121") returns false; alert(isNaN(8172)); displays false in a message box.
3) toUpperCase(): converts text to upper case. Example: var x = "bvm"; alert(x.toUpperCase()); displays BVM.
4) toLowerCase(): converts text to lower case. Example: var x = "BVM"; alert(x.toLowerCase()); displays bvm.
5) charAt(): returns the character at a particular position. Syntax: variable.charAt(index); the index of the first character is 0, of the second is 1, and so on. Example: var x = "HIGHER SECONDARY"; alert(x.charAt(4)); displays E. Also alert("The character at the first position is " + x.charAt(0)); displays H.
6) length property: returns the number of characters in a string. Syntax: variable.length; Example: var x = "HIGHER SECONDARY"; alert("The number of characters is " + x.length); displays 16 (a space is also counted as a character).
Exam Tips:
a) For each function give the name, what it does and a one-line example.
b) Remember that charAt() starts counting from index 0.
Question 22: Classify the following values in JavaScript into suitable data types: "Welcome", "123", "true", 67.4, .98, false, "hello"
Answer:
Number: 67.4 and .98
String: "Welcome", "123", "true" and "hello" (values inside quotes are strings, even if they look like numbers or Boolean values)
Boolean: false
Exam Tips:
a) Anything written inside quotation marks is a string.
b) The Boolean values are only true and false without quotes.
Question 23: What is meant by the undefined data type in JavaScript?
Answer:
Undefined is a special data type that has the single value undefined. It is the type of a variable that has been declared (or is not defined using var) but has not been given any value.
Exam Tips:
a) Example: var x; alert(x); displays undefined, because x has no value.
Question 24: Explain the operators in JavaScript.
Answer:
Operators are symbols used to perform operations.
1) Arithmetic operators
They are binary operators used for addition (+), subtraction (-), multiplication (*), division (/), modulus (%, which gives the remainder), increment (++) and decrement (--).
If x = 10 and y = 3:
| x+y | x-y | x*y | x/y | x%y |
|---|---|---|---|---|
| 13 | 7 | 30 | 3.333 | 1 |
If x = 10: document.write(++x); prints 11 (10 + 1).
If x = 10: document.write(x++); prints 10 itself (x becomes 11 afterwards).
If x = 10: document.write(--x); prints 9 (10 - 1).
If x = 10: document.write(x--); prints 10 itself (x becomes 9 afterwards).
2) Assignment operators
The statement a = b sets a to the value of b. The arithmetic assignment operators are short forms. If X = 10 and Y = 3:
| Arithmetic assignment expression | Equivalent arithmetic expression | The value of X becomes |
|---|---|---|
| X+=Y | X=X+Y | 13 |
| X-=Y | X=X-Y | 7 |
| X*=Y | X=X*Y | 30 |
| X/=Y | X=X/Y | 3.333 |
| X%=Y | X=X%Y | 1 |
3) Relational (comparison) operators
They compare two values and return either true or false. If X = 10 and Y = 3:
| X<Y | X<=Y | X>Y | X>=Y | X==Y | X!=Y |
|---|---|---|---|---|---|
| false | false | true | true | false | true |
4) Logical operators
AND (&&) and OR (||) are binary operators and NOT (!) is a unary operator. They combine relational operations and give true or false.
If X = true and Y = false:
| X&&X | X&&Y | Y&&X | Y&&Y |
|---|---|---|---|
| true | false | false | false |
For AND, both operands must be true to get true.
| X||X | X||Y | Y||X | Y||Y |
|---|---|---|---|
| true | true | true | false |
For OR, at least one operand must be true to get true.
| !X | !Y |
|---|---|
| false | true |
5) String addition (concatenation) operator (+)
It joins two strings to form a single string.
Example: x = "BVM HSS"; y = "Kalparamba"; z = x + y; Here z becomes "BVM HSSKalparamba".
If both operands are numbers, + gives a number; otherwise it gives a string:
| Operand 1 type | Operand 2 type | Operation | Resultant type |
|---|---|---|---|
| number | number | + (addition) | number |
| number | string | + | string |
| string | number | + | string |
| string | string | + | string |
Examples:
1) 8 (number) + 3 (number) = 11 (a number)
2) 8 (number) + "3" (string) = "83" (a string)
3) "8" (string) + 3 (number) = "83" (a string)
4) "8" (string) + "3" (string) = "83" (a string)
Exam Tips:
a) Name the five groups of operators and give a small example for each.
b) Remember that + between a number and a string gives a string.
c) x++ uses the value first and then increments; ++x increments first and then uses the value.
Question 25: Write JavaScript code to perform the following:
a) To check whether a variable N contains a number
b) To convert the string "scert" to all capitals
c) To convert the string "HTML" to all small letters
d) To display the message "Welcome to functions"
e) To display the third character in the string "Computer"
Answer:
a)
<HTML>
<head>
<title>check</title>
<SCRIPT Language="JavaScript">
function check()
{
var num;
num = document.frmcheck.txtnum.value;
if (isNaN(num))
alert("Not a number");
else
alert("It is a number");
}
</SCRIPT>
<BODY>
<form name="frmcheck">
Enter a number
<input type="text" name="txtnum">
<br>
<input type="button" value="show" onClick="check()">
</form>
</BODY>
</HTML>
b)
<HTML>
<head>
<title>check</title>
<SCRIPT Language="JavaScript">
function convert()
{
var str1, str2;
str1 = document.frmconvert.txtstr.value;
str2 = str1.toUpperCase();
document.frmconvert.txtupper.value = str2;
}
</SCRIPT>
<BODY>
<form name="frmconvert">
Enter a string ("scert")
<input type="text" name="txtstr">
<br>
The String in Upper Case is
<input type="text" name="txtupper">
<br>
<input type="button" value="show" onClick="convert()">
</form>
</BODY>
</HTML>
c)
<HTML>
<head>
<title>check</title>
<SCRIPT Language="JavaScript">
function convert()
{
var str1, str2;
str1 = document.frmconvert.txtstr.value;
str2 = str1.toLowerCase();
document.frmconvert.txtlower.value = str2;
}
</SCRIPT>
<BODY>
<form name="frmconvert">
Enter a string ("HTML")
<input type="text" name="txtstr">
<br>
The String in Lower Case is
<input type="text" name="txtlower">
<br>
<input type="button" value="show" onClick="convert()">
</form>
</BODY>
</HTML>
d)
<HTML>
<head>
<title>check</title>
<SCRIPT Language="JavaScript">
function display()
{
document.write("Welcome to functions");
}
</SCRIPT>
<BODY>
<SCRIPT Language="JavaScript">
display();
</SCRIPT>
</BODY>
</HTML>
e)
<HTML>
<head>
<title>check</title>
<SCRIPT Language="JavaScript">
function display()
{
var str = "Computer";
document.write(str.charAt(2));
}
</SCRIPT>
<BODY>
<SCRIPT Language="JavaScript">
display();
</SCRIPT>
</BODY>
</HTML>
The output of part (e) is m, because the index of the first character is 0, so the third character is at index 2.
Exam Tips:
a) Use isNaN() for the number check, toUpperCase() and toLowerCase() for case conversion and charAt() for a character at a position.
b) The third character is at index 2, because counting starts from 0.
Question 26: Write JavaScript code to display the length of the string "Computer".
Answer:
<HTML>
<head>
<title>length of a string</title>
</head>
<BODY>
<SCRIPT Language="JavaScript">
var str, len;
str = "Computer";
len = str.length;
alert("The length of the string Computer is " + len);
</SCRIPT>
</BODY>
</HTML>
The message displayed is: The length of the string Computer is 8.
Exam Tips:
a) length is a property, so it is written without brackets: str.length.
b) Declare the variables with var before using them.
Question 27: A web page contains a button. Write HTML code for the button which executes a function Message() on the occurrence of the following events.
a) When the user clicks the mouse on the button.
b) When the user moves the mouse over the button.
Answer:
a) <input type="button" value="Message" onClick="Message()">
b) <input type="button" value="Message" onMouseEnter="Message()">
Exam Tips:
a) onClick is for a mouse click and onMouseEnter (or onMouseOver) is for moving the pointer over the button.
Question 28: What are the advantages of writing JavaScript code in the head section of an HTML page?
Answer:
Scripts can be placed inside the <HEAD> section, and this is the widely accepted method. The body section usually contains a large volume of text and other content to be displayed on the web page, so it is kept free of code. Moreover, the head section is loaded before the body section, so the functions are already available when the page content (such as a button) needs them.
Exam Tips:
a) State two points: the head loads before the body, and the body stays free of script code.
Question 29: Design an HTML page that contains a text box to enter the marks in a given subject.
a) Write the HTML code for this web page.
b) Provide validations for this text box in a separate JavaScript file and link it with the HTML file. The validations are: (i) it should not be empty, (ii) it should be a number, (iii) it should be between 0 and 60.
c) List the advantages of writing the script in a separate file.
Answer:
a) HTML page:
<HTML>
<HEAD>
<TITLE>JavaScript</TITLE>
</HEAD>
<BODY BGCOLOR="CYAN">
<FORM NAME="frmMark">
<center>
Enter the mark
<input type="text" name="txtmark">
<br><br>
<input type="button" Value="Check" onClick="checkData()">
</center>
</FORM>
</BODY>
</HTML>
b) Step 1. Type the following in a Notepad file and save it as check.js:
function checkData()
{
var mark;
mark = document.frmMark.txtmark.value;
if (mark == "")
{
alert("Please enter a valid mark");
return;
}
if (isNaN(mark))
{
alert("Invalid mark. Try again");
return;
}
if (mark < 0 || mark > 60)
{
alert("The mark must be between 0 and 60!");
return;
}
else
alert("Correct Mark");
}
Step 2. Type the following in another Notepad file, save it as valid.html and open it in the browser. The page links the script file with the Src attribute of the SCRIPT tag. If -34 is entered, the message "The mark must be between 0 and 60!" is displayed.
<HTML>
<HEAD>
<TITLE>JavaScript - Validations</TITLE>
<SCRIPT Type="text/JavaScript" Src="check.js">
</SCRIPT>
</HEAD>
<BODY BGCOLOR="CYAN">
<FORM NAME="frmMark">
<center>
Enter the mark
<input type="text" name="txtmark">
<br><br>
<input type="button" Value="Check" onClick="checkData()">
</center>
</FORM>
</BODY>
</HTML>
c) Advantages of a separate script file: the script is saved in a file with the extension .js, so the same file can be used in many HTML files (it can be reused), and it can improve the speed of loading the pages because the browser can keep the file for later use.
Exam Tips:
a) Answer in the three parts a, b and c, as the question is split.
b) The three checks must be in the order: empty, number, range 0 to 60.
c) In the HTML file, link the script with <SCRIPT Src="check.js"></SCRIPT> in the head section.
Free study material for Computer Science
Free Kerala Board Textbook Explanations: Class 12 Computer Science Chapter 06 Client-Side Scripting Using JavaScript
Accessing Chapter 06 Client-Side Scripting Using JavaScript Solutions
Access structured Kerala Board textbook solutions for Chapter 06 Client-Side Scripting Using JavaScript. Designed in alignment with the latest academic curriculum for Class 12 Computer Science, these answers cover all end-of-chapter exercises to support daily learning and homework completion.
Concept-Driven Answers for Class 12 Computer Science
Each solution includes detailed reasoning to foster genuine comprehension of Chapter 06 Client-Side Scripting Using JavaScript concepts. Reviewing these step-by-step breakdowns allows learners to master both analytical and descriptive questions expected in school evaluations.
Maximizing Study Efficiency
These resources act as an effective roadmap for daily homework tasks and independent study. Supplement your review of Chapter 06 Client-Side Scripting Using JavaScript with official sample papers and interactive practice tests available on our platform free of charge.
FAQs
The complete and updated Kerala Plus Two Computer Science Previous Questions Chapter 6 Client-Side Scripting Using JavaScript is available for free on StudiesToday.com. These solutions for Class 12 Computer Science are as per latest Kerala Board curriculum.
Yes, our experts have revised the Kerala Plus Two Computer Science Previous Questions Chapter 6 Client-Side Scripting Using JavaScript as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.
Toppers recommend using Kerala Board language because Kerala Board marking schemes are strictly based on textbook definitions. Our Kerala Plus Two Computer Science Previous Questions Chapter 6 Client-Side Scripting Using JavaScript will help students to get full marks in the theory paper.
Yes, we provide bilingual support for Class 12 Computer Science. You can access Kerala Plus Two Computer Science Previous Questions Chapter 6 Client-Side Scripting Using JavaScript in both English and Hindi medium.
Yes, you can download the entire Kerala Plus Two Computer Science Previous Questions Chapter 6 Client-Side Scripting Using JavaScript in printable PDF format for offline study on any device.