GP Merged
GP Merged
function validation()
Prime or not var regexp=/^[0-9](4)[-]?[0-9](4)[-]?[0-9](4)$/;
<script language=”javascript”type =”text/javascript”> var x=document.getElementById("id1").value;
function isPrime(number) { if(regexp.test(x)) {
if (number < 2) { window.alert("Valid Aadhar no."); }
return false; } Else {
for (let i = 2; i <= Math.sqrt(number); i++) { window.alert("Invalid Aadhar no."); }
if (number % i === 0) { </script></head><body>
return false; // If divisible, it's not prime } } Enter Aadhar No: <input type="text" id="id1">
return true; } </script> <input type="button" value="Validate"
onclick="validation()">
<script language=”javascript”type =”text/javascript”> </body></html> //addhar number
Function OpenWindow(url) {
Window.open(url,”Msbte”,width=20,height=12top=10left=13”);
</script>
Changing the content of a window
<input type =”button”name=”b1”value =”Website1”
onclick=”OpenWindow(https://google.com)”>
<input type =”button”name=”b2”value =”Website1”
onclick=”OpenWindow(https://MSBTE.com)”> Webpage1.html
<html><body>
<script> <center><h1>Frame1</h1></center>
Var flowers = new Array(); Array 3 </body></html>
Flowers[0]=’Rose’;
flower Webpage2.html
Flowers[1]=’Mogra’; <html><body
Flowers[2]=’Lotus’; <center><h1>Frame2</h1></center>
For(var i=o; i<flower.length; i++) </body></html>
{ document.write(flower[i]+’<br>’) Webpage3.html
} <html><body>
</script> <center<h1>Frame3</h1></center>
<script> </body></html>
var mystr = “I will fail”;
varnewstr = mystr.replace(“fail”,”pass”) MainWebPage.html
document.write(newStr); <html><head>
</script>
Frame1
<frameset rows="25%,50%,25%">
I will fail ,I will not fail Frame2
<frame src="webpage1.html" />
Frame3
<frame src="webpage2.html" />
<frame src="webpage3.html" />
</frameset></head></html>
Concat () Join ()
Fruit and vegetable
using 2 radio button Array element can be Array element can be
combined by using combined by using
<html><body> concat() method of join() method of array
<h3>Select Category</h3> array object object
<input type="radio" name="type"
It does not modify the It does not modify the
onclick="showList('fruits')"> Fruits
original array original array
<input type="radio" name="type"
Does not use a Uses a separator
onclick="showList('vegetables')"> Vegetables separator, directly (default is , if not
<br><br> combines arrays/values provided )
<select id="items">
<option>Select an item</option> Eg: let arr=[1,2]; Eg: let arr=[‘a’,’b’,’c’];
</select> Let Let
<script> result=arr.concat([3,4]); result=arr.join([‘ - ’]);
function showList(type) {
const fruits = ["Apple", "Banana", "Mango"];
const vegetables = ["Carrot", "Potato", "Tomato"];
const list = document.getElementById("items");
list.innerHTML = "<option>Select an item</option>";
(type === "fruits" ? fruits : vegetables).forEach(item => {
list.innerHTML += `<option>${item}</option>`;
}); }
</script></body> </html>
<body>
<table border="1"> <tr>
<td align="center" colspan="2">
FRAME 1
</td> </tr>
<tr> <td>
FRAME 2
<ul><li>
<a href="fruits.html" target="mainframe">FRUITS</a>
</li> <li>
<a href="flowers.html" target="mainframe">FLOWERS</a>
</li> <li>
<a href="citles.html" target="mainframe">CITIES</a>
</li> </ul> </td> <td>
FRAME 3<BR>
<iframe name="mainframe"></iframe>
</td> </tr> </table> </body>